Logistic Regression

PUBLISHED: MAY 2, 20262 MIN READ

Logistics regressionClassification is a kind of problem in machine learning in which a machine learning model assigns the respective class to unseen data based

Divya Sachan
Divya SachanAuthor
walrein
#365
walrein

Logistics regression

Classification is a kind of problem in machine learning in which a machine learning model assigns the respective class to unseen data based on feature value. If the deciding classes are only two then the problem is known as a binary classification problem. If the classes are more than 2, then it is a multiclass logistic regression problem.

sigmoidal function

σ(z)=(11+ez)\sigma(z)=\left(\frac{1}{1 + e^{-z}}\right)

where

undetermined values:

This is a specific function that converts the values of Z from to in logistic regression. This function returns a value between 0 and 1 (probabilistic).

Logistic regression sigmoid function graph showing probability curve ranging from 0 to 1 with decision boundary at 0.5

σ(z)=(11+e())\sigma(z)=\left(\frac{1}{1 + e^{-(- \infty)}}\right)
σ(z)=(11+e)\sigma(z) = \left ( \frac{1}{1 + e^{\infty}} \right )
σ(z)=(1)\sigma(z) = \left ( \frac{1}{\infty} \right )
σ(z)=0\sigma(z) = 0
z=a+bxz = a + bx

σ(z)=(11+e)\sigma(z)=\left(\frac{1}{1 + e^{-\infty}}\right)
σ(z)=(11+1e)\sigma(z) = \left ( \frac{1}{1 + \frac{1}{e^{\infty}}} \right )
σ(z)=(11+1)\sigma(z) = \left ( \frac{1}{1 + \frac{1}{\infty}} \right )
σ(z)=(11+0)\sigma(z) = \left ( \frac{1}{1 + 0} \right )
σ(z)=1\sigma(z) = 1


In linear regression , is the output variable which gives a numerical value by using the sigmoidal function . We can turn the value between 0 and 1.

σ(z)=(11+ez)\sigma(z)=\left(\frac{1}{1 + e^{-z}}\right)
σ(z)=(11+e(a+bx))\sigma(z)=\left(\frac{1}{1 + e^{-(a+bx)}}\right)

where

Odd can be defined as:

px1px\frac{px}{1-px}

Where is the probability of the occurrence of .

This means:

px1px=probability of occurrence of xprobability of not occurrence of x\frac{px}{1-px}=\frac{probability\ of\ occurrence\ of\ x}{probability\ of\ not\ occurrence\ of\ x}

σ(z)=(11+ez)\sigma(z)=\left(\frac{1}{1 + e^{-z}}\right)
ez=(1σ(z))1e^{-z}=\left(\frac{1}{\sigma(z)}\right)-1
ez=1σ(z)σ(z)e^{-z} = \frac{1 - \sigma(z)}{\sigma(z)}
ez=σ(z)1σ(z)e^{z} = \frac{\sigma(z)}{1 - \sigma(z)}

where

Taking of both sides

z=log(σ(z)1σ(z))z=log\left(\frac{ \sigma(z) }{1 - \sigma(z)}\right)

In logistic regression, we obtain a value between 0 and 1, which is a probability value, and then we decide on a threshold value.

if

V (value)
T (Threshold)

Then a particular class is assigned to z, otherwise the other class.

is 0. If the result is greater than class A, otherwise class B

Binomial logistic regression.

If the number of assigned classes is two, then the logistic regression is binomial logistic regression; if the number of assigned classes is more than two, then it is multinomial logistic regression.

Logistic Regression

Logistic Degrees models are used in Binary classification and multi-classification. They are widely used in email categorization, disease detection, fraud detection, and text emotion analysis

Measurement of the performance of the machine learning model metric

confusion matrix

  • accuracy
  • precision
  • recall
  • F1 score (harmonic mean)

Cow +ve
Deer -ve

Actual ClassCowCowDeerDeerCowDeerCowDeerCowCow
Predicted ClassDeerCowDeerDeerDeerCowCowCowCowDeer
FNTPTNTNFNFPTPFPTPFN
Accuracy=TP+TNTP+TN+FP+FNAccuracy=\frac{TP+TN}{TP+TN+FP+FN}
Accuracy=3+210=510=0.5Accuracy=\frac{3+2}{10}=\frac{5}{10}=0.5
Precision=TPTP+FPPrecision=\frac{TP}{TP+FP}
Recall=TPTP+FNRecall=\frac{TP}{TP+FN}
F1Score=21Precision+1RecallF_1Score=\frac{2}{\frac{1}{Precision}+\frac{1}{Recall}}
F1Score=2(Precision×Recall)(Precision+Recall)F_1Score=\frac{2(Precision\times Recall)}{\left(Precision+Recall\right)}