0% found this document useful (0 votes)
22 views

ML Mod 3

Logistic regression predicts binary outcomes like pass/fail based on input features like hours studied. It calculates the probability of an outcome for each observation. A threshold like 0.5 is then used to classify into categories like pass/fail based on the predicted probabilities. The sigmoid function maps predicted values to probabilities between 0 and 1, making it suitable for binary classification tasks. Linear regression differs in that it predicts continuous outputs, assumes a linear relationship between inputs and outputs, and does not have a distinct decision boundary.

Uploaded by

FREDRICK AMBROSE
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

ML Mod 3

Logistic regression predicts binary outcomes like pass/fail based on input features like hours studied. It calculates the probability of an outcome for each observation. A threshold like 0.5 is then used to classify into categories like pass/fail based on the predicted probabilities. The sigmoid function maps predicted values to probabilities between 0 and 1, making it suitable for binary classification tasks. Linear regression differs in that it predicts continuous outputs, assumes a linear relationship between inputs and outputs, and does not have a distinct decision boundary.

Uploaded by

FREDRICK AMBROSE
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

1.

Write expressions for hypothesis, cost function and for parameter using gradient
descent for logistic regression. Explain each term in short.

2. Explain logistic regression with an example.

Logistic regression is a type of machine learning algorithm used for binary classification tasks, like
predicting whether an email is spam or not spam.

Here's a simple example:

Let's say we're trying to predict whether students will pass (1) or fail (0) an exam based on the
number of hours they studied. We have data for several students, where each row represents one
student:
Hours studied: 3, 5, 2, 8, 6
Result (pass/fail): 0, 1, 0, 1, 1
Logistic regression takes this data and calculates the probability of passing the exam for each
student based on the number of hours they studied. For example, it might predict a 70% chance of
passing for a student who studied for 5 hours.

Then, using a threshold (e.g., 0.5), it decides whether to predict a pass (1) or fail (0) based on
these probabilities.

In summary, logistic regression predicts binary outcomes (like pass or fail) based on input features
(like hours studied), making it useful for classification tasks.

3. What a note on convex and non-convex curves.

Convex curves:

● Simple curves that always curve upwards or are flat.


● Imagine a hill: you can't go down and then up; it's always up or flat.
● In optimization, finding the minimum is straightforward because there's
only one.

Non-convex curves:

● Curves that can curve in any direction.


● Picture a roller coaster: it goes up, down, and all around.
● In optimization, finding the minimum is trickier because there might be
multiple, and they're not always easy to find.

4. Write expression for sigmoid function. Explain utility of Sigmoid function in logistic
regression.

Sigmoid function is useful to map any predicted values of probabilities into another value
between 0 and 1.

The function's shape resembles an "S" curve, starting from 0 and gradually increasing
towards 1 as z becomes larger.
- As z becomes more negative, g(z) approaches 0, and as z becomes more positive, g(z)
approaches 1.
- The sigmoid function is particularly useful in logistic regression because it converts the
output of the linear equation (which can be any real number) into a probability between 0
and 1.
This probability represents the likelihood of a binary outcome (e.g., pass or fail, spam or
not spam), making it suitable for binary classification tasks.

5. Differentiate between Linear and Logistic regression

​ 5. Application:
● Linear regression is suitable for predicting real-valued outputs like house prices, stock prices,
etc.
● Logistic regression is commonly used for binary classification tasks like spam detection,
medical diagnosis, etc.

​ 6. Assumption:
● Linear regression assumes a linear relationship between input and output variables.
● Logistic regression assumes a linear relationship between the log odds of the outcome and
the input variables.
​ 7. Optimization Algorithm:
● Linear regression often uses methods like Ordinary Least Squares (OLS) or gradient descent
for optimization.
● Logistic regression uses gradient descent or other optimization algorithms to minimize the
log loss function.

​ 8. Model Interpretability:
● Linear regression coefficients represent the change in the output variable for a one-unit
change in the input variable.
● Logistic regression coefficients represent the change in the log odds of the outcome for a
one-unit change in the input variable.

​ 9. Handling Outliers:
● Linear regression is sensitive to outliers, which can significantly impact the model's
performance.
● Logistic regression is less affected by outliers due to its robustness in handling binary
outcomes.

​ 10. Decision Boundary:
● Linear regression doesn't have a distinct decision boundary since it's continuous.
● Logistic regression has a decision boundary (typically at 0.5 probability) separating the two
classes.

You might also like