Logistic Regression: Machine Learning Interview Prep 04

Shahidullah Kawsar
5 min readJun 1, 2021

--

Logistic regression is like a detective figuring out whether someone is guilty or innocent based on evidence. Instead of directly predicting a number like in linear regression, it predicts the probability of an outcome, like whether an email is spam or not. It uses a mathematical function called the logistic function to squash the output between 0 and 1. By analyzing past data, logistic regression learns to make predictions about future outcomes, making it a handy tool for predicting categorical outcomes.

Let’s check your basic knowledge of Logistic Regression. Here are 10 multiple-choice questions for you and there’s no time limit. Have fun!

Question 1: Logistic regression is used for ___?
(A) classification
(B) regression
(C) clustering
(D) All of these

Question 2: Logistic Regression is a Machine Learning algorithm that is used to predict the probability of a ___?
(A) categorical independent variable
(B) categorical dependent variable.
(C) numerical dependent variable.
(D) numerical independent variable.

Question 3: You are predicting whether an email is spam or not. Based on the features, you obtained an estimated probability to be 0.75. What’s the meaning of this estimated probability? (select two)
(A) there is a 25% chance that the email will be spam
(B) there is a 75% chance that the email will be spam
(C) there is a 75% chance that the email will not be spam
(D) there is a 25% chance that the email will not be spam

Question 4: In a logistic regression model, the decision boundary can be ___.
(A) linear
(B) non-linear
(C) both (A) and (B)
(D) none of these

Question 5: What’s the cost function of the logistic regression?
(A) Sigmoid function
(B) Logistic Function
(C) both (A) and (B)
(D) none of these

Figure 1: Linear Regression VS Logistic Regression Graph [1]

Question 6: Why cost function which has been used for linear regression can’t be used for logistic regression?
(A) Linear regression uses mean squared error as its cost function. If this is used for logistic regression, then it will be a non-convex function of its parameters. Gradient descent will converge into the global minimum only if the function is convex.
(B) Linear regression uses mean squared error as its cost function. If this is used for logistic regression, then it will be a convex function of its parameters. Gradient descent will converge into the global minimum only if the function is convex.
(C) Linear regression uses mean squared error as its cost function. If this is used for logistic regression, then it will be a non-convex function of its parameters. Gradient descent will converge into the global minimum only if the function is non-convex.
(D) Linear regression uses mean squared error as its cost function. If this is used for logistic regression, then it will be a convex function of its parameters. Gradient descent will converge into the global minimum only if the function is non-convex.

Figure 2: Convex and non-convex cost function [2]

Question 7: You are predicting whether an email is spam or not. Based on the features, you obtained an estimated probability to be 0.75. What’s the meaning of this estimated probability? The threshold to differ the classes is 0.5.
(A) The email is not spam
(B) The email is spam
(C) Can’t determine
(D) both (A) and (B)

Question 8: What’s the hypothesis of logistic regression?
(A) to limit the cost function between 0 and 1
(B) to limit the cost function between -1 and 1
(C) to limit the cost function between -infinity and +infinity
(D) to limit the cost function between 0 and +infinity

Question 9: Which one is not true?
(A) If we take the weighted sum of inputs as the output as we do in Linear Regression, the value can be more than 1 but we want a value between 0 and 1. That’s why Linear Regression can’t be used for classification tasks.

(B) Logistic Regression is a generalized Linear Regression in the sense that we don’t output the weighted sum of inputs directly, but we pass it through a function that can map any real value between 0 and 1.
(C) The value of the sigmoid function always lies between 0 and 1

(D) Logistic Regression is used to determine the value of a continuous dependent variable

Question 10: In a logistic regression, if the predicted logit is 0, what’s the transformed probability?
(A) 0
(B) 1
(C) 0.5
(D) 0.05

The solutions will be published in the next quiz Machine Learning Quiz 05: Decision Tree (Part 1).

Happy learning. If you like the questions and enjoy taking the test, please subscribe to my email list for the latest ML questions, follow my Medium profile, and leave a clap for me. Feel free to discuss your thoughts on these questions in the comment section. Don’t forget to share the quiz link with your friends or LinkedIn connections. If you want to connect with me on LinkedIn: my LinkedIn profile.

Solution of Machine Learning Quiz 03: Support Vector Machine - 1(A), 2(C), 3(A), 4(A), 5(C), 6(A), 7(A, C), 8(A), 9(A, D), 10(C, D)

References:

[1] Introduction to Logistic Regression: https://towardsdatascience.com/introduction-to-logistic-regression-66248243c148

[2] Logistic Regression — Detailed Overview: https://towardsdatascience.com/logistic-regression-detailed-overview-46c4da4303bc

[3] Building a Logistic Regression in Python: https://towardsdatascience.com/building-a-logistic-regression-in-python-301d27367c24

--

--

Shahidullah Kawsar
Shahidullah Kawsar

Written by Shahidullah Kawsar

Data Scientist, IDARE, Houston, TX

Responses (1)