CS 445 Introduction to Machine Learning Logistic Regression Instructor: Dr. Kevin Molloy
Review Linear regression Finding the weights to assign to a polynomial so that the resulting line minimizes the "loss". β(π¦ ! , π¦ " , β¦ π¦ # ) = π₯ $ + π₯ ! π¦ ! + . . +π₯ # π¦ # β π¦ = π₯ % π¦ This function h(x) (hypothesis function) makes a real valued prediction (regression). ! " β # !, $ ! β& π§ ' β π₯ ( π¦ ' " Linear Regression π π₯ =
Approach for Linear Regression ! ") β # !, $ ! β& π§ ' β π₯ ( π¦ ' " Linear Regression π π₯ = Optimize (find the min) of the loss function using the derivatives: πL(w) = 1 ()) (y ' β w + x ' ) N ) π¦ ' πw ! "#$..& πL(w) = 1 (y " β w + x " ) N ) πw $ "#$..&
Linear Regression Algorithm Make predictions using current w and compute loss 1. Compute derivative and update w's 2. When loss change is a little STOP, otherwise, go back to 1. 3.
Logistic Regression X X X X World's WORST algorithm name O O O O Transform linear regression into a classification algorithm h(x) >= 0.5, predict y = 1 (X class) h(x) < 0.5, predict y = 0 () class)
Map Function to Values Between 0 and 1 ! Sigmoid (z) = !" # #$ 1 1 + π $% % &
Different Loss Function 1 1 + π $% % & ! ") β # !, $ ! β& π§ ' β π₯ ( π¦ ' " Linear Regression π π₯ =
Cost Function for Linear Regression Loss( h ( x ), y ) = β log π , π¦ ππ π§ = 1 β log 1 β π , π¦ ππ π§ = 0
Cost Function for Linear Regression Loss( h ( x ), y ) = β log π , π¦ ππ π§ = 1 β log 1 β π , π¦ ππ π§ = 0 When y = 1: f(x) = 1, then Cost = 0 (since (-log(1) = 0) f(x) = 0 , then the loss (or penalty) will be very large.
Cost Function for Linear Regression Loss( h ( x ), y ) = β log π , π¦ ππ π§ = 1 β log 1 β π , π¦ ππ π§ = 0 When y = 0: f(x) = 0, then Cost = 0 (since (-log(1 βf(x)) = 0) f(x) = , then the loss (or penalty) will be very large.
Logistic Regression Loss Loss( h ( x ), y ) = β log π , π¦ ππ π§ = 1 β log 1 β π , π¦ ππ π§ = 0 . π π§ = 1 π¦ ) ) / ! π¦ π π§ = 0 π¦ ) ) - 0 / ! Loss( h ( x ), y ) = β )#-
Recommend
More recommend