In the last few days I learned about Logistic Regression as one method to solve classification problems.
Classification problems are similar to regression problems, except that the values which will be predicted by our hypothesis will be discrete numbers. E.g. a binary classification problem only predicts values in which y can take or . So there are just two classes to predict. An example for binary classification would be predicting if an incoming email is spam or not spam. There would be two classes: One class of emails which are spam () and one class of emails which are not spam (). Another example for binary classification would be credit card fraud detection. There would also be two classes: One class of transactions which are fraud () and one class of transactions which are not fraud ().
Of course classification problems can also have more classes than two. One classification problem with three classes is the famous iris data set. The data set consists of 150 samples of three different flowers. Every flower in the data set is described by four features (sepals and petals length and width).
One form of the hypothesis function for a binary classification problems would be as following:
This form of hypothesis for classification uses the sigmoid function . It can there either be called sigmoid function or logistic function. In the following I will use logistic function and logistic regression model to describe the hypothesis.
The Logistic function looks as following:
Because the function maps any real number to it is very useful for defining a hypothesis for a binary classification problem.
Every will be classified as and every will be interpreted as .
In the logistic function every inputs which is greater or equal to zero will be greater than or equals than 0.5 as output (like you can see above in the graph).
Therefore we can say that every will be classified as and every will be classified as .
A decision boundary is called the line which separates the are and . The line will be directly created by the hypothesis function.
E.g. if then if which results to . So the decision boundary will be a straight vertical line one the graph where . Everything on the left excluding the points on will be in the class and everything on the right including the points on will be in the class of .
Logistic Regression does also work for non linear models through changing the shape of , e.g. through feature engineering.