CHAP 7 : Logistic Regression Flashcards
What is logistic regression?
It is a supervised learning algorithm. It is a classfication algorithm that assigns data to a discrete set of classes
Give example(s) of classification problems.
- Email classification : spam or not spam
- Financial data analysis : fraud / not fraud
- Credit analysis : approve or deny credit
- Marketing : will buy or wont buy
- basically a binary classificaion (only 2 classes)
What is the logistic function for logisitic regression? (analogous to best fit line eqn of linear regression)?
y hat = g(W.X^T),
g(X) = 1/(1+e^-z),
thus y hat = 1/(1+e^-(W.X^T))
What is the name for the logistic function?
Sigmoid function
From the values generated by the sigmoid function, how do the values get classified into class 0 or 1 by the classifier?
if the value < 0.5, the class value = 0. If the value >= 0.5, class value = 1.
What is the error function given by in logistic regression?
E(W) = 1/2N (summation (y(i) - yhat(i)^2) – refer to notes
Why cant we use the same error function (average MSE) as linear regression for logisitic regression?
There will be many local minima and the algorithm may be stuck in a local minima.
What is the cost function for logistic regression?
cost (yhat(x), y) =
-log(yhat(x)) if y = 1;
-log(1-yhat(x)) if y = 0.
See notes [we can rerite error function using the cost function]
How does the gradient descent algorithm work for logistic regression?
- initialise W with random values or zeros
- Loop till convergence
for each W(j) in W do :
w(j) = w(j) + L . 1/N summation (y(i) - y hat (xi))x(j)(i)) , where j –> jth col, ith col
see notes for equation.
What is a confusion matrix?
A confusion matrix is a performance measurement for machine learning classification
It presents a table layout of the different outcomes of the prediction and results of a classification problem and helps visualize its outcomes.
Values : True positive, true negative, false positive, false negative.
What is the difference between the training dataset and the validation dataset?
Training dataset is a set of examples used for learning, that is to fit the parameters of the classifier. A validation dataset contains different samples to evaluate trained ML models.
[The validation dataset is useful when it comes to hyper-parameter tuning and model selection. The validation examples included in this set will be used to find the optimal values for the hyper-parameters of the model under consideration.]
From the confusion matrix, there are 4 other metrics to evaluate classification output. What are they?
- Precision
- Recall (sensitivity)
- F1 score
- Support
What is precision, how is it calculated?
Precision is the ratio of correctly predicted positive observations to the total predicted positive observations. (High precision relates to the low false positive rate. )
Precision = TP/(TP+FP)
TP: true positive ; FP : False positive
What is recall and how is it calculated?
It is the ratio of correctly predicted positive observations to the all observations in actual class .
Recall = TP / TP+FN
FN: False negatives
What is F1 score and how is it calculated?
F1 Score is the weighted average of Precision and Recall
- F1 Score = 2*(Recall * Precision) / (Recall + Precision)