Maria Florina Balcan 02072018 Na ID: 841860
Download Pdf The PPT/PDF document "Logistic Regression" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
1 Maria - Florina Balcan 02/07/2018 Logist
Maria - Florina Balcan 02/07/2018 Logistic Regression Naïve Bayes Recap Classifier: 2 × ( ¬ ) ൠ¦ ¡¬ y P ( Â È Â¬ ) NB Assumption: NB Classifier: Assume parametric form for P ( X È Y ) and P ( Y ) P X à Ç· X d Y ൠ෣ i à à d P ( X i È Y ) NB ¬ ൠ¦ ¡¬ y à·£ i à à d P ¬ i  P (  ) à Estimate p
2 arameters using MLE/MAP and plug in Gene
arameters using MLE/MAP and plug in Generative vs. Discriminative Classifiers 3 Generative classifiers (e.g. Naïve Bayes ) Assume some functional form for P(X,Y) (or P(X|Y) and P(Y)) Why not learn P(Y|X) directly? Or better yet, why not learn the decision boundary directly? Discriminative classifiers (e.g. Logistic Regression ) Assume some functional form for P(Y|X) or for the decision boundary Estimate pa
3 rameters of P(X|Y), P(Y) directly from t
rameters of P(X|Y), P(Y) directly from training data Use Bayes rule to calculate P(Y|X) Estimate parameters of P(Y|X) directly from training data Logistic Regression 4 Assumes the following functional form for P(Y|X): Logistic function (or Sigmoid): Logistic function applied to a linear function of the data z logit (z) Features can be discrete or continuous! P Y ൠΠX ൠΠΠ+ ¬¤ ( â ( « à + Ï i Â
4 « i X i ) ) ൠ¬¤ ( « à +
« i X i ) ) ൠ¬¤ ( « à + Ï i « i X i ) ¬¤ ( « à + Ï i « i X i ) + Î à à à exà® à z Logistic Regression is a Linear Classifier! 5 (Linear Decision Boundary) Assumes the following functional form for P(Y|X): Decision boundary: « à + à· i « i X i ൠΠP Y ൠΠX > P Y ൠΠX ǽ « à + à· i « i X i > Πǽ P Y ൠΠX ൠΠΠ+ ¬¤ ( â ( « à + Ï i « i X i ) ) àµ
5 x0099;¬¤ ( « à + Ï i « i X i )
x0099;¬¤ ( « à + Ï i « i X i ) ¬¤ ( « à + Ï i « i X i ) + Î Logistic Regression is a Linear Classifier! 6 Assumes the following functional form for P(Y|X): Assumes a linear decision boundary: there are weights Ý¥ i s.t. when « à + Ï i « i X i > Î , the example is more likely to be positive, and when this linear function is negative ( « à + Ï i « i X i < Î ) the example is more likely to be nega
6 tive. « à + à· i « i X i ൠΠP
tive. « à + à· i « i X i ൠΠP Y ൠΠX ൠΠΠ+ ¬¤ ( â ( « à + Ï i « i X i ) ) ൠ¬¤ ( « à + Ï i « i X i ) ¬¤ ( « à + Ï i « i X i ) + Π« à + Ï i « i X i ൠΠ, Ý Ý àµ Î Ý àµ à à « à + Ï i « i X i Õ® Ï , Ý Ý àµ Î Ý Õ® Π« à + Ï i « i X i Õ® â Ï , Ý Ý àµ Î Ý Õ® Î 7 Logistic Regression is a Linear Classifier! Ö® P Y ൠΠX ൠÎ
7 ¬¤ ( « à + Ï i « i X i
¬¤ ( « à + Ï i « i X i ) + Î Ö® P Y ൠΠX P ( Y àµ Î È X ) ൠ¬¤ ( « à + à· i « i X i ) > Πǽ Ö® « à + à· i « i X i > Πǽ Assumes the following functional form for P(Y|X): P Y ൠΠX ൠΠΠ+ ¬¤ ( â ( « à + Ï i « i X i ) ) ൠ¬¤ ( « à + Ï i « i X i ) ¬¤ ( « à + Ï i « i X i ) + Î Training Logistic Regression 9 Ä°ÍÆÆ ÄºÆÄ¢ÇÆ
8 ¢ ÆÆ Ä¡Å¯ÆÄÆÇ Ä¢ÆÄƢƢůĺůĢÄ
¢ ÆÆ Ä¡Å¯ÆÄÆÇ Ä¢ÆÄƢƢůĺůĢÄƬůÆÆÍ© P Y ൠΠX dz « ൠ¬¤ ( « à + Ï i « i X i ) Î + ¬¤ ( « à + Ï i « i X i ) P Y ൠΠX dz « ൠΠΠ+ ¬¤ ( « à + Ï i « i X i ) How to learn the parameters « à dz « à dz Ç· dz « d ǽ Training data: X j dz Y j j à à ྠX j ൠX à j dz Ç· dz X d j Maximum Likelihood Estimates: à·¯ ܱ MLà ൠ¦ ¡
9 95;¬ ܱ à·£ j à à ྠP X j dz Y j
95;¬ ܱ à·£ j à à ྠP X j dz Y j ܱ Donât ï¨ave a model for P ( X ) or P ( X È Y ) â only for P ( Y È X ) BÇƬ ƬŬİÆÄ°ÍÆ¢ Ä ÆÆÆÄ¡ÆÄ°ÆÍ« Training Logistic Regression 10 How to learn the parameters ܱ à«« dz ܱ૬ dz Ç· ܱ Ü ? Training data: X j dz Y j j à à ྠX j ൠX à j dz Ç· dz X d j Maximum ( Conditional ) Likelihood Estimates à·¯ ܱ MCLà ൠ¦ ¡¬ ܱ à·£ j à à
10 ྠP Y j X j dz ܱ Discriminative phil
ྠP Y j X j dz ܱ Discriminative philosophy Î DÆÆÍƬ ÇÄƢƬİ İĺĺÆÆƬ ÆÄ°ÄÆÆůÆÅ¢ tÎÎͧ ĺÆÄ¢ÇÆ¢ on P(Y|X) ΠƬŬÄƬÍÆ¢ ÄÆÆ Æ¬Å¬ÄƬ ÆÄƬƬİÆÆ¢ ĺÆÆ Ä¢ÆÄƢƢůĺůĢÄƬůÆÆÍ Expressing Conditional log Likelihood 11 P Y ൠΠX dz « ൠ¬¤ ( « à + Ï i « i X i ) Î + ¬¤ ( « à + Ï i « i X i ) P Y ൠΠX dz « ൠΠΠ+ ¬¤ ( « à + Ï i « i
11 X i )  ܱ ز  ¢ à·£ j P (  j È Ü²
X i )  ܱ ز  ¢ à·£ j P (  j È Ü² j dz ܱ ) ൠ෠j  j « à + à· i à à d « i ¬ i j â  ¢ Î + ¬¤ « à + à· i à à d « i ¬ i j Maximizing Conditional log Likelihood 12 Good news :  ( ܱ ) is concave in w. Local optimum = global optimum ¡¬ ܱ  ( ܱ ) ز  ¢ à·£ j P (  j È Ü² j dz ܱ ) ൠ෠j  j « à + à· i à à d « i ¬ i j â  ¢ Î + ¬¤ « à + à· i à
12 à d « i ¬ i j Bad news : no close
à d « i ¬ i j Bad news : no closed - form solution to maximize Ý ( ܱ ) Good news : concave functions easy to optimize (unique maximum) Optimizing concave/convex function 13 Conditional likelihood for Logistic Regression is concave Gradient: Learning rate, ï¨ 0 Update rule: Maximum of a concave function = minimum of a convex function Gradient Ascent (concave)/ Gradient Descent (convex) ߪ ܱ  ܱ àµ
13 à  ܱ à « à dz Ç· dz à  ܱ
à  ܱ à « à dz Ç· dz à  ܱ à « ྠȱ ܱ ൠÉߪ ܱ  ܱ « i ( à® à à ) ൠ« i à® + É à  ܱ à « i ᬠ஠Gradient Ascent for Logistic Regression 14 look at actual labels of the examples, compare them to our current predictions, and then for each example j we multiply that difference by the feature value ¬ i j and then add them up. Predict what current weight thinks label Y should be Gradie
14 nt ascent algorithm: iterate until chang
nt ascent algorithm: iterate until change < à For ൠΠdz Ç· dz ǵ repeat « à à® à à ൠ« à à® + É à· j  j â à·³ P Y j àµ Î È Ü² j dz ܱ ஠« i à® à à ൠ« i à® + É à· j ¬ i j  j â à·³ P Y j àµ Î È Ü² j dz ܱ à® Gradient Ascent for Logistic Regression 15 Gradient ascent is simplest of optimization approaches à e.g., Newton method, Conjugate gradient ascent,
15 IRLS (see Bishop 4.3.3) Predict what cur
IRLS (see Bishop 4.3.3) Predict what current weight thinks label Y should be Gradient ascent algorithm: iterate until change < à For ൠΠdz Ç· dz ǵ repeat « à à® à à ൠ« à à® + É à· j  j â à·³ P Y j àµ Î È Ü² j dz ܱ ஠« i à® à à ൠ« i à® + É à· j ¬ i j  j â à·³ P Y j àµ Î È Ü² j dz ܱ à® Effect of step - size ï¨ 16 Large ï¨ Ö® Fast convergence but larger resid
16 ual error Also possible oscillations Sma
ual error Also possible oscillations Small ï¨ Ö® Slow convergence but small residual error vŬÄƬÍÆ¢ ÄÆÆ aÎCÎPYͪ >ÆÇ ÄÄ¡ÆÇƬ aAtÍ 17 One common approach is to define priors on w ¤ ܱ Y dz Ü ×± P Y Ü Ç³ ܱ ¤ ܱ à Normal distribution, zero mean, identity covariance à ͰtÇƢŬİƢͱ ÆÄÆÄÆİƬİÆÆ¢ ƬÆÇÄÆĬƢ ÇÄ°ÆÆ Corresponds to Regularization à Helps avoid very large weights and ove
17 rfitting à More on this later in the se
rfitting à More on this later in the semester M(C)AP estimate ܱ × àµ Â¦ ¡¬ ܱ  ¢ ¤ ܱ à·£ j à à ྠP  j È Ü² j dz ܱ What you should know 18 LR is a linear classifier: decision rule is a hyperplane LR optimized by conditional likelihood à no closed - form solution à concave Ö® global optimum with gradient ascent à Maximum conditional a posteriori corresponds to regu