A blog for computer science passionates.

Wednesday 23 October 2019

Types of Classification Algorithms : Part - 1 Logistic Regression

Hello!!! to all CS Passionate,

In this article, we are going to learn different types of classification algorithms.
There are lots of different algorithms to solve classification problems. In which some of them are,
  1. Logistic regression
  2. Naïve Bayes classifier
  3. Nearest neighbor
  4. Support vector machine
  5. Decision tree
  6. Neural networks
  7. Random forest
And more, here in this part - 1 we are going to learn about,

Logistic Regression

Logistic regression is actually a type of regression, but it returns binary type of result so, we can use this algorithm for classification problems also, such as image is cat or not.
Logistic regression is a statistical method for regression analysis classification to conduct when the dependent variable is binary. such as pass/fail, yes/no, true/false, etc. it is a predictive analysis method like other regression methods. But we need to use logistic regression when we have a categorical target at that time we cannot use linear regression.

As it does not work linearly, it does not work for the straight line so, it performs the logistic function (the sigmoid function), as its results are between 0 and 1.
The formula for sigmoid activation function (logistic function):

1/(1+exp(-x))

(1.0)
The above formula returns a real-valued number, it returns numbers between 0 and 1.
Fig. 1.0 Logistic function (sigmoid curve). It generates output between 0 and 1.

How does Logistic regression works?

Logistic regression works on the same equation as linear regression. The linear regression equation is something like,
y^(i) = w0+w1x1(i)+w2x2(i)+...+wnxn(i)
(1.1)
The output of logistic regression σ(wTx). where σ is the logistic sigmoid function it uses the above formula (1.0). Let's assign wTx to z, so now our equation for logistic regression is σ(z). So, z = w0+w1x1(i)+w2x2(i)+...+wnxn(i) Now, to calculate logistic regression we need to work on probability. So, our equation becomes P(y(i) = 1) = 1/(1+exp(-z)).


Now, let's take an example, to predict cancer.

In the above example, we can classify cancer is 'malignant' or 'benign'. Hope you enjoy.
In the next article, we will learn about Naive Bayes Classifier. Till then learn logistic regression....☺

No comments:

Post a Comment