LOGISTIC REGRESSION David Kauchak CS451 – Fall 2013.

Slides:



Advertisements
Similar presentations
Modeling of Data. Basic Bayes theorem Bayes theorem relates the conditional probabilities of two events A, and B: A might be a hypothesis and B might.
Advertisements

Linear Regression.
Prof. Navneet Goyal CS & IS BITS, Pilani
Brief introduction on Logistic Regression
Regularization David Kauchak CS 451 – Fall 2013.
Linear Classifiers/SVMs
Pattern Recognition and Machine Learning
PERCEPTRON LEARNING David Kauchak CS 451 – Fall 2013.
Supervised Learning Recap
CSC321: 2011 Introduction to Neural Networks and Machine Learning Lecture 10: The Bayesian way to fit models Geoffrey Hinton.
PROBABILISTIC MODELS David Kauchak CS451 – Fall 2013.
CMPUT 466/551 Principal Source: CMU
Chapter 4: Linear Models for Classification
PROBABILISTIC MODELS David Kauchak CS451 – Fall 2013.
What is Statistical Modeling
Visual Recognition Tutorial
x – independent variable (input)
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
Machine Learning CUNY Graduate Center Lecture 3: Linear Regression.
1 Linear Classification Problem Two approaches: -Fisher’s Linear Discriminant Analysis -Logistic regression model.
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)
Classification and Prediction: Regression Analysis
CSCI 347 / CS 4206: Data Mining Module 04: Algorithms Topic 06: Regression.
Crash Course on Machine Learning
1 Linear Methods for Classification Lecture Notes for CMPUT 466/551 Nilanjan Ray.
Physics 114: Lecture 15 Probability Tests & Linear Fitting Dale E. Gary NJIT Physics Department.
PATTERN RECOGNITION AND MACHINE LEARNING
Machine Learning CUNY Graduate Center Lecture 3: Linear Regression.
EM and expected complete log-likelihood Mixture of Experts
ADVANCED CLASSIFICATION TECHNIQUES David Kauchak CS 159 – Fall 2014.
1 Logistic Regression Adapted from: Tom Mitchell’s Machine Learning Book Evan Wei Xiang and Qiang Yang.
HADOOP David Kauchak CS451 – Fall Admin Assignment 7.
IID Samples In supervised learning, we usually assume that data points are sampled independently and from the same distribution IID assumption: data are.
Learning Theory Reza Shadmehr logistic regression, iterative re-weighted least squares.
1 CS546: Machine Learning and Natural Language Discriminative vs Generative Classifiers This lecture is based on (Ng & Jordan, 02) paper and some slides.
PATTERN RECOGNITION AND MACHINE LEARNING CHAPTER 3: LINEAR MODELS FOR REGRESSION.
Data Mining Practical Machine Learning Tools and Techniques Chapter 4: Algorithms: The Basic Methods Section 4.6: Linear Models Rodney Nielsen Many of.
BOOSTING David Kauchak CS451 – Fall Admin Final project.
ICS 178 Introduction Machine Learning & data Mining Instructor max Welling Lecture 6: Logistic Regression.
CS 782 – Machine Learning Lecture 4 Linear Models for Classification  Probabilistic generative models  Probabilistic discriminative models.
Empirical Research Methods in Computer Science Lecture 7 November 30, 2005 Noah Smith.
CSE 446 Logistic Regression Winter 2012 Dan Weld Some slides from Carlos Guestrin, Luke Zettlemoyer.
LARGE MARGIN CLASSIFIERS David Kauchak CS 451 – Fall 2013.
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.
PRIORS David Kauchak CS159 Fall Admin Assignment 7 due Friday at 5pm Project proposals due Thursday at 11:59pm Grading update.
CHAPTER 6 Naive Bayes Models for Classification. QUESTION????
ECE 5984: Introduction to Machine Learning Dhruv Batra Virginia Tech Topics: –Classification: Logistic Regression –NB & LR connections Readings: Barber.
Linear Models for Classification
Over-fitting and Regularization Chapter 4 textbook Lectures 11 and 12 on amlbook.com.
Logistic Regression William Cohen.
Machine Learning 5. Parametric Methods.
Lecture 3: MLE, Bayes Learning, and Maximum Entropy
Review of statistical modeling and probability theory Alan Moses ML4bio.
Machine Learning CUNY Graduate Center Lecture 6: Linear Regression II.
CPH Dr. Charnigo Chap. 11 Notes Figure 11.2 provides a diagram which shows, at a glance, what a neural network does. Inputs X 1, X 2,.., X P are.
CSC321: Lecture 8: The Bayesian way to fit models Geoffrey Hinton.
PATTERN RECOGNITION AND MACHINE LEARNING CHAPTER 1: INTRODUCTION.
Probability David Kauchak CS158 – Fall 2013.
Large Margin classifiers
Probability Theory and Parameter Estimation I
Empirical risk minimization
10701 / Machine Learning.
Announcements HW4 due today (11:59pm) HW5 out today (due 11/17 11:59pm)
ECE 5424: Introduction to Machine Learning
Ying shen Sse, tongji university Sep. 2016
Mathematical Foundations of BME Reza Shadmehr
Empirical risk minimization
David Kauchak CS159 Spring 2019
Presentation transcript:

LOGISTIC REGRESSION David Kauchak CS451 – Fall 2013

Admin Assignment 7 CS Lunch on Thursday

Priors Coin1 data: 3 Heads and 1 Tail Coin2 data: 30 Heads and 10 tails Coin3 data: 2 Tails Coin4 data: 497 Heads and 503 tails If someone asked you what the probability of heads was for each of these coins, what would you say?

Training revisited From a probability standpoint, what we’re really doing when we’re training the model is selecting the Θ that maximizes: That we pick the most likely model parameters given the data i.e.

Estimating revisited We can incorporate a prior belief in what the probabilities might be To do this, we need to break down our probability (Hint: Bayes rule)

Estimating revisited What are each of these probabilities?

Priors likelihood of the data under the model probability of different parameters, call the prior probability of seeing the data (regardless of model)

Priors Does p(data) matter for the argmax?

Priors likelihood of the data under the model probability of different parameters, call the prior What does MLE assume for a prior on the model parameters?

Priors likelihood of the data under the model probability of different parameters, call the prior -Assumes a uniform prior, i.e. all Θ are equally likely! -Relies solely on the likelihood

A better approach We can use any distribution we’d like This allows us to impart addition bias into the model

Another view on the prior Remember, the max is the same if we take the log: We can use any distribution we’d like This allows us to impart addition bias into the model Does this look like something we’ve seen before?

Regularization vs prior loss function based on the data likelihood based on the data regularizer prior fit model bias

Prior for NB Uniform prior Dirichlet prior λ = 0 increasing

Prior: another view What happens to our likelihood if, for one of the labels, we never saw a particular feature? MLE: Goes to 0!

Prior: another view Adding a prior avoids this!

Smoothing training data for each label, pretend like we’ve seen each feature value occur in λ additional examples Sometimes this is also called smoothing because it is seen as smoothing or interpolating between the MLE and some other distribution

Basic steps for probabilistic modeling Which model do we use, i.e. how do we calculate p(feature, label)? How do train the model, i.e. how to we we estimate the probabilities for the model? How do we deal with overfitting? Probabilistic models Step 1: pick a model Step 2: figure out how to estimate the probabilities for the model Step 3 (optional): deal with overfitting

Joint models vs conditional models We’ve been trying to model the joint distribution (i.e. the data generating distribution): However, if all we’re interested in is classification, why not directly model the conditional distribution:

A first try: linear - Nothing constrains it to be a probability - Could still have combination of features and weight that exceeds 1 or is below 0 Any problems with this?

The challenge Linear model +∞ -∞ 1 0 probability We like linear models, can we transform the probability into a function that ranges over all values?

Odds ratio Rather than predict the probability, we can predict the ratio of 1/0 (positive/negative) Predict the odds that it is 1 (true): How much more likely is 1 than 0. Does this help us?

Odds ratio Linear model +∞ -∞ +∞ 0 odds ratio Where is the dividing line between class 1 and class 0 being selected?

Odds ratio Does this suggest another transformation? …. odds ratio We’re trying to find some transformation that transforms the odds ratio to a number that is -∞ to +∞

Log odds (logit function) Linear regression +∞ -∞ +∞ -∞ odds ratio How do we get the probability of an example?

Log odds (logit function) … anyone recognize this?

Logistic function

Logistic regression How would we classify examples once we had a trained model? If the sum > 0 then p(1)/p(0) > 1, so positive if the sum < 0 then p(1)/p(0) < 1, so negative Still a linear classifier (decision boundary is a line)

Training logistic regression models How should we learn the parameters for logistic regression (i.e. the w’s)? parameters

MLE logistic regression assume labels 1, -1 Find the parameters that maximize the likelihood (or log-likelihood) of the data:

MLE logistic regression We want to maximize, i.e. Look familiar? Hint: anybody read the book?

MLE logistic regression Surrogate loss functions:

logistic regression: three views linear classifier conditional model logistic linear model minimizing logistic loss

Overfitting If we minimize this loss function, in practice, the results aren’t great and we tend to overfit Solution?

Regularization/prior or What are some of the regularizers we know?

Regularization/prior L2 regularization: Gaussian prior: p(w,b) ~

Regularization/prior L2 regularization: Gaussian prior: Does the λ make sense?

Regularization/prior L2 regularization: Gaussian prior:

Regularization/prior L1 regularization: Laplacian prior: p(w,b) ~

Regularization/prior L1 regularization: Laplacian prior:

L1 vs. L2 L1 = Laplacian priorL2 = Gaussian prior

Logistic regression Why is it called logistic regression?

A digression: regression vs. classification Raw dataLabel extract features f 1, f 2, f 3, …, f n featuresLabel classification: discrete (some finite set of labels) regression: real value

linear regression Given some points, find the line that best fits/explains the data Our model is a line, i.e. we’re assuming a linear relationship between the feature and the label value How can we find this line? f1f1 response (y)

Linear regression Learn a line h that minimizes some loss/error function: feature (x) response (y) Sum of the individual errors: 0/1 loss!

Error minimization How do we find the minimum of an equation? Take the derivative, set to 0 and solve (going to be a min or a max) Any problems here? Ideas?

Linear regression feature response squared error is convex!

Linear regression Learn a line h that minimizes an error function: in the case of a 2d line: function for a line feature response

Linear regression We’d like to minimize the error Find w 1 and w 0 such that the error is minimized We can solve this in closed form

Multiple linear regression If we have m features, then we have a line in m dimensions weights

Multiple linear regression We can still calculate the squared error like before Still can solve this exactly!

Logistic function

Logistic regression Find the best fit of the data based on a logistic