ECE 5424: Introduction to Machine Learning

Slides:



Advertisements
Similar presentations
Pattern Classification & Decision Theory. How are we doing on the pass sequence? Bayesian regression and estimation enables us to track the man in the.
Advertisements

CMPUT 466/551 Principal Source: CMU
Artificial Intelligence Lecture 2 Dr. Bo Yuan, Professor Department of Computer Science and Engineering Shanghai Jiaotong University
Classification and risk prediction
Logistic Regression Rong Jin. Logistic Regression Model  In Gaussian generative model:  Generalize the ratio to a linear model Parameters: w and c.
Today Linear Regression Logistic Regression Bayesians v. Frequentists
Bayes Classifier, Linear Regression 10701/15781 Recitation January 29, 2008 Parts of the slides are from previous years’ recitation and lecture notes,
Review Rong Jin. Comparison of Different Classification Models  The goal of all classifiers Predicating class label y for an input x Estimate p(y|x)
Logistic Regression 10701/15781 Recitation February 5, 2008 Parts of the slides are from previous years’ recitation and lecture notes, and from Prof. Andrew.
Review of Lecture Two Linear Regression Normal Equation
Crash Course on Machine Learning
EE513 Audio Signals and Systems Statistical Pattern Classification Kevin D. Donohue Electrical and Computer Engineering University of Kentucky.
Crash Course on Machine Learning Part II
CSE 446 Gaussian Naïve Bayes & Logistic Regression Winter 2012
ECE 5984: Introduction to Machine Learning Dhruv Batra Virginia Tech Topics: –Classification: Naïve Bayes Readings: Barber
1 Logistic Regression Adapted from: Tom Mitchell’s Machine Learning Book Evan Wei Xiang and Qiang Yang.
1 CS546: Machine Learning and Natural Language Discriminative vs Generative Classifiers This lecture is based on (Ng & Jordan, 02) paper and some slides.
CSE 446 Perceptron Learning Winter 2012 Dan Weld Some slides from Carlos Guestrin, Luke Zettlemoyer.
Generative verses discriminative classifier
ECE 5984: Introduction to Machine Learning Dhruv Batra Virginia Tech Topics: –Statistical Estimation (MLE, MAP, Bayesian) Readings: Barber 8.6, 8.7.
CS 782 – Machine Learning Lecture 4 Linear Models for Classification  Probabilistic generative models  Probabilistic discriminative models.
CSE 446 Logistic Regression Winter 2012 Dan Weld Some slides from Carlos Guestrin, Luke Zettlemoyer.
Machine Learning Recitation 6 Sep 30, 2009 Oznur Tastan.
Ch 4. Linear Models for Classification (1/2) Pattern Recognition and Machine Learning, C. M. Bishop, Summarized and revised by Hee-Woong Lim.
Machine Learning CUNY Graduate Center Lecture 4: Logistic Regression.
ECE 5984: Introduction to Machine Learning Dhruv Batra Virginia Tech Topics: –Classification: Logistic Regression –NB & LR connections Readings: Barber.
Linear Models for Classification
ECE 5984: Introduction to Machine Learning Dhruv Batra Virginia Tech Topics: –Regression Readings: Barber 17.1, 17.2.
Over-fitting and Regularization Chapter 4 textbook Lectures 11 and 12 on amlbook.com.
ECE 5984: Introduction to Machine Learning Dhruv Batra Virginia Tech Topics: –Ensemble Methods: Bagging, Boosting Readings: Murphy 16.4; Hastie 16.
Regress-itation Feb. 5, Outline Linear regression – Regression: predicting a continuous value Logistic regression – Classification: predicting a.
Logistic Regression William Cohen.
CSE 446 Logistic Regression Perceptron Learning Winter 2012 Dan Weld Some slides from Carlos Guestrin, Luke Zettlemoyer.
ECE 5984: Introduction to Machine Learning Dhruv Batra Virginia Tech Topics: –(Finish) Expectation Maximization –Principal Component Analysis (PCA) Readings:
Naive Bayes (Generative Classifier) vs. Logistic Regression (Discriminative Classifier) Minkyoung Kim.
Introduction to Machine Learning Nir Ailon Lecture 11: Probabilistic Models.
ECE 5984: Introduction to Machine Learning Dhruv Batra Virginia Tech Topics: –(Finish) Model selection –Error decomposition –Bias-Variance Tradeoff –Classification:
PATTERN RECOGNITION AND MACHINE LEARNING CHAPTER 1: INTRODUCTION.
Why does it work? We have not addressed the question of why does this classifier performs well, given that the assumptions are unlikely to be satisfied.
Matt Gormley Lecture 4 September 12, 2016
Matt Gormley Lecture 3 September 7, 2016
Usman Roshan CS 675 Machine Learning
Deep Feedforward Networks
ECE 5424: Introduction to Machine Learning
ECE 5424: Introduction to Machine Learning
Dhruv Batra Georgia Tech
Probability Theory and Parameter Estimation I
ECE 5424: Introduction to Machine Learning
ECE 5424: Introduction to Machine Learning
Generative verses discriminative classifier
ECE 5424: Introduction to Machine Learning
ECE 5424: Introduction to Machine Learning
ECE 5424: Introduction to Machine Learning
10701 / Machine Learning.
Discriminative and Generative Classifiers
ECE 5424: Introduction to Machine Learning
ECE 5424: Introduction to Machine Learning
ECE 5424: Introduction to Machine Learning
ECE 5424: Introduction to Machine Learning
Classification Discriminant Analysis
ECE 5424: Introduction to Machine Learning
Where did we stop? The Bayes decision rule guarantees an optimal classification… … But it requires the knowledge of P(ci|x) (or p(x|ci) and P(ci)) We.
EE513 Audio Signals and Systems
Logistic Regression.
Pattern Recognition and Machine Learning
Parametric Methods Berlin Chen, 2005 References:
Multivariate Methods Berlin Chen
Multivariate Methods Berlin Chen, 2005 References:
Recap: Naïve Bayes classifier
Linear Discrimination
Presentation transcript:

ECE 5424: Introduction to Machine Learning Topics: Classification: Logistic Regression NB & LR connections Readings: Barber 17.4 Stefan Lee Virginia Tech

Administrativia HW1 Graded (C) Dhruv Batra

Administrativia HW2 Review Lecture Tues Midterm Thursday Due: Monday, 10/3, 11:55pm Implement linear regression, Naïve Bayes, Logistic Regression Review Lecture Tues Midterm Thursday In class, class timing, open notes/book Closed internet (C) Dhruv Batra

Recap of last time (C) Dhruv Batra

Naïve Bayes (your first probabilistic classifier) x Classification y Discrete (C) Dhruv Batra

Classification Learn: h:X  Y X – features Y – target classes Suppose you know P(Y|X) exactly, how should you classify? Bayes classifier: Why? Slide Credit: Carlos Guestrin

Error Decomposition Approximation/Modeling Error Estimation Error You approximated reality with model Estimation Error You tried to learn model with finite data Optimization Error You were lazy and couldn’t/didn’t optimize to completion Bayes Error Reality just sucks http://psych.hanover.edu/JavaTest/SDT/ROC.html (C) Dhruv Batra

Generative vs. Discriminative Generative Approach (Naïve Bayes) Estimate p(x|y) and p(y) Use Bayes Rule to predict y Discriminative Approach Estimate p(y|x) directly (Logistic Regression) Learn “discriminant” function h(x) (Support Vector Machine) (C) Dhruv Batra

The Naïve Bayes assumption Features are independent given class: More generally: How many parameters now? Suppose X is composed of d binary features (C) Dhruv Batra Slide Credit: Carlos Guestrin

Generative vs. Discriminative Generative Approach (Naïve Bayes) Estimate p(x|y) and p(y) Use Bayes Rule to predict y Discriminative Approach Estimate p(y|x) directly (Logistic Regression) Learn “discriminant” function h(x) (Support Vector Machine) (C) Dhruv Batra

Today: Logistic Regression Main idea Think about a 2 class problem {0,1} Can we regress to P(Y=1 | X=x)? Meet the Logistic or Sigmoid function Crunches real numbers down to 0-1 Model In regression: y ~ N(w’x, λ2) Logistic Regression: y ~ Bernoulli(σ(w’x)) (C) Dhruv Batra

Understanding the sigmoid w0=2, w1=1 w0=0, w1=1 w0=0, w1=0.5 Go to projector to remind all of logistic regression and do the w direction thing (C) Dhruv Batra Slide Credit: Carlos Guestrin

Visualization (C) Dhruv Batra Slide Credit: Kevin Murphy

Expressing Conditional Log Likelihood (C) Dhruv Batra Slide Credit: Carlos Guestrin

Maximizing Conditional Log Likelihood Bad news: no closed-form solution to maximize l(w) Good news: l(w) is concave function of w! (C) Dhruv Batra Slide Credit: Carlos Guestrin

Slide Credit: Greg Shakhnarovich (C) Dhruv Batra Slide Credit: Greg Shakhnarovich

Careful about step-size (C) Dhruv Batra Slide Credit: Nicolas Le Roux

(C) Dhruv Batra Slide Credit: Fei Sha

When does it work? (C) Dhruv Batra

(C) Dhruv Batra Slide Credit: Fei Sha

Slide Credit: Greg Shakhnarovich (C) Dhruv Batra Slide Credit: Greg Shakhnarovich

(C) Dhruv Batra Slide Credit: Fei Sha

(C) Dhruv Batra Slide Credit: Fei Sha

(C) Dhruv Batra Slide Credit: Fei Sha

(C) Dhruv Batra Slide Credit: Fei Sha

Optimizing concave function – Gradient ascent Conditional likelihood for Logistic Regression is concave  Find optimum with gradient ascent Gradient: Learning rate, >0 Update rule: (C) Dhruv Batra Slide Credit: Carlos Guestrin

Maximize Conditional Log Likelihood: Gradient ascent (C) Dhruv Batra Slide Credit: Carlos Guestrin

Gradient ascent algorithm: iterate until change <  Gradient Ascent for LR Gradient ascent algorithm: iterate until change <  For i=1,…,n, repeat (C) Dhruv Batra Slide Credit: Carlos Guestrin

(C) Dhruv Batra

That’s all M(C)LE. How about M(C)AP? One common approach is to define priors on w Normal distribution, zero mean, identity covariance “Pushes” parameters towards zero Corresponds to Regularization Helps avoid very large weights and overfitting More on this later in the semester MAP estimate (C) Dhruv Batra Slide Credit: Carlos Guestrin

Large parameters  Overfitting If data is linearly separable, weights go to infinity Leads to overfitting Penalizing high weights can prevent overfitting (C) Dhruv Batra Slide Credit: Carlos Guestrin

Gradient of M(C)AP (C) Dhruv Batra Slide Credit: Carlos Guestrin

MLE vs MAP Maximum conditional likelihood estimate Maximum conditional a posteriori estimate (C) Dhruv Batra Slide Credit: Carlos Guestrin

HW2 Tips Naïve Bayes Logistic Regression Train_NB Test_NB Implement “factor_tables” -- |Xi| x |Y| matrices Prior |Y| x 1 vector Fill entries by counting + smoothing Test_NB argmax_y P(Y=y) P(Xi=xi)… TIP: work in log domain Logistic Regression Use small step-size at first Make sure you maximize log-likelihood not minimize it Sanity check: plot objective (C) Dhruv Batra

Connections between NB & LR Finishing up: Connections between NB & LR (C) Dhruv Batra

Logistic regression vs Naïve Bayes Consider learning f: X  Y, where X is a vector of real-valued features, <X1 … Xd> Y is boolean Gaussian Naïve Bayes classifier assume all Xi are conditionally independent given Y model P(Xi | Y = k) as Gaussian N(ik,i) model P(Y) as Bernoulli(q,1-q) What does that imply about the form of P(Y|X)? Cool!!!! (C) Dhruv Batra Slide Credit: Carlos Guestrin

Derive form for P(Y|X) for continuous Xi (C) Dhruv Batra Slide Credit: Carlos Guestrin

Ratio of class-conditional probabilities (C) Dhruv Batra Slide Credit: Carlos Guestrin

Derive form for P(Y|X) for continuous Xi (C) Dhruv Batra Slide Credit: Carlos Guestrin

Gaussian Naïve Bayes vs Logistic Regression Set of Gaussian Naïve Bayes parameters (feature variance independent of class label) Set of Logistic Regression parameters Not necessarily Representation equivalence But only in a special case!!! (GNB with class-independent variances) But what’s the difference??? LR makes no assumptions about P(X|Y) in learning!!! Loss function!!! Optimize different functions  Obtain different solutions (C) Dhruv Batra Slide Credit: Carlos Guestrin

Naïve Bayes vs Logistic Regression Consider Y boolean, Xi continuous, X=<X1 ... Xd> Number of parameters: NB: 4d +1 (or 3d+1) LR: d+1 Estimation method: NB parameter estimates are uncoupled LR parameter estimates are coupled (C) Dhruv Batra Slide Credit: Carlos Guestrin

G. Naïve Bayes vs. Logistic Regression 1 [Ng & Jordan, 2002] Generative and Discriminative classifiers Asymptotic comparison (# training examples  infinity) when model correct GNB (with class independent variances) and LR produce identical classifiers when model incorrect LR is less biased – does not assume conditional independence therefore LR expected to outperform GNB (C) Dhruv Batra Slide Credit: Carlos Guestrin

G. Naïve Bayes vs. Logistic Regression 2 [Ng & Jordan, 2002] Generative and Discriminative classifiers Non-asymptotic analysis convergence rate of parameter estimates, d = # of attributes in X Size of training data to get close to infinite data solution GNB needs O(log d) samples LR needs O(d) samples GNB converges more quickly to its (perhaps less helpful) asymptotic estimates (C) Dhruv Batra Slide Credit: Carlos Guestrin

Some experiments from UCI data sets Naïve bayes Logistic Regression Some experiments from UCI data sets (C) Dhruv Batra

What you should know about LR Gaussian Naïve Bayes with class-independent variances representationally equivalent to LR Solution differs because of objective (loss) function In general, NB and LR make different assumptions NB: Features independent given class assumption on P(X|Y) LR: Functional form of P(Y|X), no assumption on P(X|Y) 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 regularization Convergence rates GNB (usually) needs less data LR (usually) gets to better solutions in the limit (C) Dhruv Batra Slide Credit: Carlos Guestrin