20
Logistic Regression Week 3 – Soft Computing By Yosi Kristian.

Logistic Regression Week 3 – Soft Computing By Yosi Kristian

Embed Size (px)

Citation preview

Page 1: Logistic Regression Week 3 – Soft Computing By Yosi Kristian

Logistic RegressionWeek 3 – Soft ComputingBy Yosi Kristian.

Page 2: Logistic Regression Week 3 – Soft Computing By Yosi Kristian

Classificationo Email: Spam / Not Spam?o Online Transactions: Fraudulent (Yes / No)?o Tumor: Malignant / Benign ?

0: “Negative Class” (e.g., benign tumor)

1: “Positive Class” (e.g., malignant tumor)

Page 3: Logistic Regression Week 3 – Soft Computing By Yosi Kristian

Using Linear Regression ( fail )

Tumor Size

Threshold classifier output at 0.5:

If , predict “y = 1”

If , predict “y = 0”

Tumor Size

Malignant ?

(Yes) 1

(No) 0

0,5

Page 4: Logistic Regression Week 3 – Soft Computing By Yosi Kristian

Other Reason

Classification: y = 0 or 1

Linear regression can be > 1 or < 0

Logistic Regression:

Although it has the term regression, Logistic Regression is actually a Classification Algorithm, the name was giver only for historical reasons.

Page 5: Logistic Regression Week 3 – Soft Computing By Yosi Kristian

HYPOTHESISREPRESENTATION

Page 6: Logistic Regression Week 3 – Soft Computing By Yosi Kristian

Logistic Regression Model

Sigmoid function / Logistic function

Want

1

0.5

0

Page 7: Logistic Regression Week 3 – Soft Computing By Yosi Kristian

Interpretation of Hypothesis Output

= estimated probability that y = 1 on input x

Tell patient that 70% chance of tumor being malignant

Example: If

“probability that y = 1, given x, parameterized by ”

Page 8: Logistic Regression Week 3 – Soft Computing By Yosi Kristian

DECISION BOUNDARY

Page 9: Logistic Regression Week 3 – Soft Computing By Yosi Kristian

Boundaries Logistic regression

Suppose predict “ “ if

predict “ “ if

z

1

Page 10: Logistic Regression Week 3 – Soft Computing By Yosi Kristian

Decision Boundary

x1

x2

1 2 3

1

2

3

Predict “ “ if

Page 11: Logistic Regression Week 3 – Soft Computing By Yosi Kristian

Non-linear decision boundaries

x1

x2

Predict “ “ if

x1

x2

1-1

-1

1

Page 12: Logistic Regression Week 3 – Soft Computing By Yosi Kristian

COST FUNCTION

Page 13: Logistic Regression Week 3 – Soft Computing By Yosi Kristian

Linear Regression Cost function (fail)

Linear regression:

“non-convex” “convex”

Page 14: Logistic Regression Week 3 – Soft Computing By Yosi Kristian

Logistic regression cost function

If y = 1

10

Page 15: Logistic Regression Week 3 – Soft Computing By Yosi Kristian

Logistic regression cost function

If y = 0

10

Page 16: Logistic Regression Week 3 – Soft Computing By Yosi Kristian

SIMPLIFIED COST FUNCTION AND GRADIENT DESCENT

Page 17: Logistic Regression Week 3 – Soft Computing By Yosi Kristian

Logistic regression cost function

Page 18: Logistic Regression Week 3 – Soft Computing By Yosi Kristian

Logistic regression cost function

Output

To fit parameters :

To make a prediction given new :

Page 19: Logistic Regression Week 3 – Soft Computing By Yosi Kristian

Gradient Descent

Want :

Repeat

(simultaneously update all )

Page 20: Logistic Regression Week 3 – Soft Computing By Yosi Kristian

Gradient Descent

Want :

(simultaneously update all )

Repeat

Algorithm looks identical to linear regression!