Posts

Showing posts from 2018

Maximizing cos(x) + cos(y) + cos(z)

Image
It's been a while since my last blog. Since it's getting closer to IEEEXtreme 12.0 I thought of sharing an algorithmic challenge I tried in one of the past competitive programming contests. I had a thought of penning down some insight into this challenge ever since I solved this. For whatever the reason (maybe for the reason I managed to solve this!) this challenge seems to be quite exciting. First of all, I must say that I am not the author of this challenge and in fact, I can't remember the place I encountered this challenge. (If you happen to know the original author please let me know so that I could give credit to him here) I even created a Hackerrank problem using this. (You can have a try, link ) First, let's take a look at the task. Find the maximum value of $\cos{x} + \cos{y} + \cos{z}$ given that $x + y + z = n$ where $x, y, z, n$ are positive integers. The input constraint was $3 \leq n \leq 3 \times 10^6$ The task description is clear and there is n...

Accuracy, F Measure (aka F1 score), precision, recall

If you have gone through machine learning or any statistics related research literature I am pretty sure that you have come across cases where something called F Measure is calculated than the accuracy in some tests. In this short blog let's clear out what is F Measure and why is it needed rather than the simple accuracy. Let's say in a binary classification task some rare incident is predicted. (Can be predicting the occurrence of a landslide given the weather conditions, landslides are rare :-P) If that rare incident only occurs for 1% of the time, a binary classification model predicting all negative (or 0) will get an accuracy of 99%. Does that make the model a good one? No! (Usually, a model having an accuracy of 99% will be dope!) Now you see there is a problem with the accuracy. The solution is to use F Measure or F1 score or F score or... Let's look at the equation for calculating F measure. \[F1 = \frac{2}{\frac{1}{Precision} + \frac{1}{Recall}}\] If yo...