Logistic Regression: Online, Lazy, Kernelized, Sequential, etc.

Similar documents
Conditional Random Field

Undirected Graphical Models

Probabilistic Models for Sequence Labeling

A brief introduction to Conditional Random Fields

Probabilistic Graphical Models & Applications

Conditional Random Fields and beyond DANIEL KHASHABI CS 546 UIUC, 2013

Sequence labeling. Taking collective a set of interrelated instances x 1,, x T and jointly labeling them

Classification CE-717: Machine Learning Sharif University of Technology. M. Soleymani Fall 2012

CPSC 340: Machine Learning and Data Mining. MLE and MAP Fall 2017

Sequence Modelling with Features: Linear-Chain Conditional Random Fields. COMP-599 Oct 6, 2015

Part 4: Conditional Random Fields

Machine Learning - Waseda University Logistic Regression

Stein Variational Gradient Descent: A General Purpose Bayesian Inference Algorithm

CS 340 Lec. 16: Logistic Regression

Logistic Regression Review Fall 2012 Recitation. September 25, 2012 TA: Selen Uguroglu

Sequential Supervised Learning

Intelligent Systems (AI-2)

Machine Learning: Chenhao Tan University of Colorado Boulder LECTURE 5

Lecture 2 Machine Learning Review

Probabilistic Graphical Models

Generative Clustering, Topic Modeling, & Bayesian Inference

Naïve Bayes classification

Machine Learning. Lecture 4: Regularization and Bayesian Statistics. Feng Li.

Probabilistic modeling. The slides are closely adapted from Subhransu Maji s slides

Naïve Bayes classification. p ij 11/15/16. Probability theory. Probability theory. Probability theory. X P (X = x i )=1 i. Marginal Probability

Stochastic Gradient Descent

Probabilistic Graphical Models

Introduction to Logistic Regression and Support Vector Machine

COMS 4721: Machine Learning for Data Science Lecture 10, 2/21/2017

Graphical Models for Collaborative Filtering

CPSC 340: Machine Learning and Data Mining

Classification Logistic Regression

Intelligent Systems (AI-2)

CSC 412 (Lecture 4): Undirected Graphical Models

Lecture 5: Linear models for classification. Logistic regression. Gradient Descent. Second-order methods.

Machine Learning for Structured Prediction

Pattern Recognition and Machine Learning

ECE521 week 3: 23/26 January 2017

Linear & nonlinear classifiers

CRF for human beings

Probabilistic Graphical Models

Statistical NLP for the Web Log Linear Models, MEMM, Conditional Random Fields

A graph contains a set of nodes (vertices) connected by links (edges or arcs)

Linear Regression (9/11/13)

Gaussian and Linear Discriminant Analysis; Multiclass Classification

Machine Learning for NLP

> DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE GRAVIS 2016 BASEL. Logistic Regression. Pattern Recognition 2016 Sandro Schönborn University of Basel

HOMEWORK #4: LOGISTIC REGRESSION

ECE521 lecture 4: 19 January Optimization, MLE, regularization

STA 4273H: Statistical Machine Learning

Midterm Review CS 7301: Advanced Machine Learning. Vibhav Gogate The University of Texas at Dallas

Machine Learning. Lecture 3: Logistic Regression. Feng Li.

Parametric Models. Dr. Shuang LIANG. School of Software Engineering TongJi University Fall, 2012

Linear classifiers: Overfitting and regularization

Logistic Regression. COMP 527 Danushka Bollegala

Machine Learning. Classification, Discriminative learning. Marc Toussaint University of Stuttgart Summer 2015

Logistic Regression. INFO-2301: Quantitative Reasoning 2 Michael Paul and Jordan Boyd-Graber SLIDES ADAPTED FROM HINRICH SCHÜTZE

MLPR: Logistic Regression and Neural Networks

Outline. MLPR: Logistic Regression and Neural Networks Machine Learning and Pattern Recognition. Which is the correct model? Recap.

Introduction to Machine Learning Midterm, Tues April 8

Maximum Likelihood, Logistic Regression, and Stochastic Gradient Training

Machine Learning for NLP

Outline. Supervised Learning. Hong Chang. Institute of Computing Technology, Chinese Academy of Sciences. Machine Learning Methods (Fall 2012)

Midterm Review CS 6375: Machine Learning. Vibhav Gogate The University of Texas at Dallas

Machine Learning Tom M. Mitchell Machine Learning Department Carnegie Mellon University. September 20, 2012

Probabilistic classification CE-717: Machine Learning Sharif University of Technology. M. Soleymani Fall 2016

Regression with Numerical Optimization. Logistic

Density Estimation. Seungjin Choi

Kaggle.

Mark your answers ON THE EXAM ITSELF. If you are not sure of your answer you may wish to provide a brief explanation.

HOMEWORK #4: LOGISTIC REGRESSION

CPSC 540: Machine Learning

Case Study 1: Estimating Click Probabilities. Kakade Announcements: Project Proposals: due this Friday!

Overfitting, Bias / Variance Analysis

Notes on Machine Learning for and

Comments. x > w = w > x. Clarification: this course is about getting you to be able to think as a machine learning expert

σ(a) = a N (x; 0, 1 2 ) dx. σ(a) = Φ(a) =

Chris Bishop s PRML Ch. 8: Graphical Models

Logistic Regression & Neural Networks

Log-Linear Models, MEMMs, and CRFs

Learning MN Parameters with Approximation. Sargur Srihari

Logistic Regression. Machine Learning Fall 2018

Conditional Random Fields for Sequential Supervised Learning

Introduction to Probabilistic Machine Learning

Bits of Machine Learning Part 1: Supervised Learning

ECE 5984: Introduction to Machine Learning

Classification: Logistic Regression from Data

Statistical Data Mining and Machine Learning Hilary Term 2016

NONLINEAR CLASSIFICATION AND REGRESSION. J. Elder CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition

Machine Learning Basics III

Lecture 3. Linear Regression II Bastian Leibe RWTH Aachen

MIDTERM: CS 6375 INSTRUCTOR: VIBHAV GOGATE October,

Generative v. Discriminative classifiers Intuition

Machine Learning

Bayesian Support Vector Machines for Feature Ranking and Selection

Nonparametric Bayesian Methods (Gaussian Processes)

Introduction to Machine Learning

Learning MN Parameters with Alternative Objective Functions. Sargur Srihari

Neural Network Training

Lecture 9: PGM Learning

Transcription:

Logistic Regression: Online, Lazy, Kernelized, Sequential, etc. Harsha Veeramachaneni Thomson Reuter Research and Development April 1, 2010 Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 1 / 56

1 Logistic Regression (Plain and Simple) Introduction to logistic regression 2 Learning Algorithm Log-Likelihood Gradient Descent Lazy Updates 3 Kernelization 4 Sequence Tagging Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 2 / 56

1 Logistic Regression (Plain and Simple) Introduction to logistic regression 2 Learning Algorithm Log-Likelihood Gradient Descent Lazy Updates 3 Kernelization 4 Sequence Tagging

What is Logistic Regression? It s called regression but it s actually for classification. Assume we have a classification problem 1 from x R d to y {0, 1}. Assume further that we want the classifier to output posterior class probabilities. Example: Say we have x = [x 1, x 2 ] and a binary classification problem. We would like a classifier that can compute p(y = 0 x) and p(y = 1 x) 1 Everything we say applies to multi-class problems but we ll restrict the talk to binary for simplicity Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 3 / 56

In the Beginning There Was a Model 2 Say we have two scoring functions s 0 (x) and s 1 (x) and we write p(y = i x) = s i (x) s 0 (x)+s 1 (x). As long as s i (x) > 0 we obtain a probability like number. Say we project x along some vector and map the projection to a positive quantity. For example, s i (x) = e w i T x 2 All models are wrong. Some are useful. Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 4 / 56

Modeling Continued According to our definition above where β = w 1 w 0 f (z) = exp(z) 1+exp(z) p(y = 1 x) = = s 1 (x) s 0 (x) + s 1 (x) exp(w T 1 x) exp(w T 0 x) + exp(w T 1 x) = exp((w 1 w 0 ) T x) 1 + exp((w 1 w 0 ) T x) = exp(βt x) 1 + exp(β T x) is called the logistic function. Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 5 / 56

Model Therefore And p(y = 1 x) = exp(βt x) 1 + exp(β T x) p(y = 0 x) = For our two feature example we have 1 1 + exp(β T x) p(y = 1 x) = exp(β 1x 1 +β 2 x 2 ) 1+exp(β 1 x 1 +β 2 x 2 ) Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 6 / 56

Logistic Function Pictures Figure: Logistic function in one variable. Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 7 / 56

Adding in a Bias Term Once we can compute p(y x) we can get a minimum error-rate classifier by assigning all feature vectors with p(y = 1 x) > 0.5 to class y = 1 and 0 otherwise. What is p(y = 1 x) when x = 0? p(y = 1 x) = exp(0) 1+exp(0) = 0.5 Therefore the classification boundary always passes through the origin. We change this behavior by augmenting our model with a bias term. Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 8 / 56

Adding in a Bias Term So we write p(y = 1 x) = exp(β 0+β T x) 1+exp(β 0 +β T x) For the two feature example it becomes p(y = 1 x) = exp(β 0+β 1 x 1 +β 2 x 2 ) 1+exp(β 0 +β 1 x 1 +β 2 x 2 ) We can rewrite this as p(y = 1 x) = exp( β T x) 1+exp( β T x) where β = [β 0, β 1, β 2 ] and x = [1, x 1, x 2 ] Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 9 / 56

Logistic Function Pictures Figure: Logistic function in two variables, β 0 = 0, β 1 = 1.0, β 2 = 1.0 Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 10 / 56

Logistic Function Pictures Figure: Logistic function in two variables, β 0 = 20.0, β 1 = 1.0, β 2 = 1.0 Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 11 / 56

Logistic Function Pictures Figure: Logistic function in two variables, β 0 = 0.0, β 1 = 3.0, β 2 = 1.0 Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 12 / 56

Logistic Function Pictures Figure: Logistic function in two variables, β 0 = 0, β 1 = 0.1, β 2 = 0.1 Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 13 / 56

Logistic Function Pictures Figure: Derivative of the logistic function in two variables, β 0 = 0, β 1 = 0.1, β 2 = 0.1 Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 14 / 56

Decoding and Inference At test time the given feature vector x is classified (decoded) as class 1 if p(y = 1 x) > p(y = 0 x) exp(β T x) 1 + exp(β T x) > 1 1 + exp(β T x) exp(β T x) > 1 β T x > 0 Inference: If we need the probability, we need to compute the partition function (1 + exp(β T x)) Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 15 / 56

Some Justification for the Model Why exp()? The( log-odds) ratio log p(y=1 x) p(y=0 x) = β T x is an affine function of the observations. The log-odds ratio is an affine function of the sufficient statistics if the class-conditional distributions are from a fixed exponential family. The converse also true 3. Logistic regression same as MAXENT classification (under the right constraints on the features). 3 Banerjee (2007), An Analysis of Logistic Models: Exponential Family Connections and Online Performance. Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 16 / 56

1 Logistic Regression (Plain and Simple) Introduction to logistic regression 2 Learning Algorithm Log-Likelihood Gradient Descent Lazy Updates 3 Kernelization 4 Sequence Tagging

Learning Suppose we are given a labeled data set D = {(x 1, y 1 ), (x 2, y 2 ),..., (x N, y N )} From this data we wish to learn the logistic regression parameter (weight) vector β. Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 17 / 56

Learning If we assume that the labeled examples are i.i.d., the likelihood of the data is l(d; β) = p(d β) = N i=1 p(y = y i x i ; β) Or the log-likelihood is L(D; β) = log l(d; β) = N i=1 log p(y = y i x i ; β) Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 18 / 56

Maximum Likelihood (ML) Estimation The Maximum Likelihood (ML) estimate of the parameter vector is given by ˆβ = arg max β = arg max β p(d β) = arg max L(D β) N log p(y = y i x i ; β) i=1 β What happens if there is a feature which is zero for all the examples except one? Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 19 / 56

Maximum A Posteriori (MAP) Estimation We place a prior on β that penalizes large values. For example a Gaussian prior: p(β) = N(β; 0, σ 2 I) The posterior probability of the β is given by p(β D) = p(d β)p(β) p(d) So instead of ML we can obtain the Maximum A Posteriori (MAP) estimate ˆβ = arg max β p(β D) = arg max p(d β)p(β) = arg max (log p(d β) + log p(β)) β ( N = arg max β i=1 How is this maximization actually done? β log p(y = y i x i ; β) + log p(β) Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 20 / 56 )

Gradient Ascent Start with β = 0 and iteratively move along the direction of steepest ascent. Since the function we are optimizing is concave, any local maximum we find is also the global maximum. We need to be able to compute the gradient ( β p(β D)) at any point. The choice of the size of the step is important. Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 21 / 56

Gradient Ascent Gradient = β p(β D) = ( β 0 p(β D), β 1 p(β D),...) β j p(β D) = β j { So the update rule would be N log p(y = y i x i ; β) + log p(β)} i=1 β (t+1) j = β (t) j + ζ β j p(β D) Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 22 / 56

Stochastic Gradient Ascent Gradient = β p(β D) = ( β 0 p(β D), β 1 p(β D),...) We can write β j p(β D) = = = = β j { N i=1 N i=1 N log p(y = y i x i ; β) + log p(β)} i=1 (log p(y = y i x i ; β)) + log p(β) β j β j ( log p(y = y i x i ; β) + 1 ) log p(β) β j N β j N g(x i, y i ) (At a fixed value of β) i=1 Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 23 / 56

Stochastic Gradient Ascent 4 The update rule is β (t+1) j = β (t) j = β (t) j = β (t) j β (t) j + ζ β j p(β D) + ζ N g(x i, y i ) i=1 ( ) 1 N + Nζ g(x }{{} i, y i ) N i=1 }{{} + ηe[g(x, y)] 4 Usually talked about as Stochastic Gradient Descent (SGD), because minimization is canonical. Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 24 / 56

Stochastic Gradient Ascent We could randomly sample a small batch of L examples from the training set to estimate E[g(x, y)]. What if we went to extreme and made L = 1? We obtain online (incremental) learning. Can be shown to converge to the same optimum under some reasonable assumptions. Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 25 / 56

Stochastic Gradient Ascent The learning algorithm in its entirety is vspace0.1in Algorithm 1: SGD Input: D = {x i, y i } i=1...n, η, MaxEpochs, Convergence Threshold Output: β β 0 for e = 1 : MaxEpochs Log-Likelihood Convergence do for i = 1 : N do β β + ηg(x i, y i ) return β If x R d, complexity is O(Nd). Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 26 / 56

Gradient Calculation Let us now compute g(x i, y i ). g(x i, y i ) = log p(y = y i x i ; β) + 1 log p(β) β j N β j Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 27 / 56

Gradient Calculation If y i = 1 β j log p(y = y i x i ; β) = ( exp(β T x i ) log β j 1 + exp(β T x i ) = β T x i log(1 + exp(β T x i )) β j β j = x ij exp(βt x) 1 + exp(β T x) x ij = x ij p(y = 1 x i ; β)x ij = x ij (1 p(y = 1 x i ; β)) ) Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 28 / 56

Gradient Calculation Similarly, if y i = 0 β j log p(y = y i x i ; β) = ( log β j 1 1 + exp(β T x i ) ) = β j log(1 + exp(β T x i )) = exp(βt x i ) 1 + exp(β T x i ) x ij = x ij (1 p(y = 0 x i ; β)) Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 29 / 56

Gradient Calculation Therefore we may write β j log p(y = y i x i ; β) = ( 1) y i +1 x ij (1 p(y = y i x i ; β)) Note: β is in the span of the example feature vectors. (Representer Theorem) Question: How many β j will be updated if for an example all its feature values are zero (x i = 0)? Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 30 / 56

Lazy Update If we ignore the prior, for each example, we only need to update the coordinates of β where the feature vector is non-zero. Makes learning very fast if the feature vectors are sparse. Complexity reduces to O(Ns), where s is the average number of non-zero feature values. What happens when we add the prior? Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 31 / 56

Lazy Update If the prior is Gaussian p(β) = A exp( 0.5 β 2 σ 2 ) where A does not depend on β. Therefore log p(β) = C + log exp( 0.5 β 2 σ 2 ) = C 0.5 β 2 σ 2 β j log p(β) = β j ) (C 0.5 β 2 σ 2 = 1 σ 2 β j Because of the contribution of the prior to the gradient, all the coordinates of β need to be updated. Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 32 / 56

Lazy Update The solution is to update lazily 5. Still only update the coordinates corresponding to non-zero features. For each coordinate keep track of number of examples u seen since last update. For each non-zero feature coordinate penalize the β value u times. Technical detail clip to avoid crossing zero. 5 Carpenter (2008), Lazy sparse stochastic gradient descent for regularized multinomial logistic regression Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 33 / 56

One Slide about Multi-Class Logistic Regression Say the class labels come from a finite set y {0, 1,..., M 1}. We define 6 p(y x) exp(β T y x) Therefore p(y x) = exp(βt y x) Py exp(βt y x). The above discussion about learning/sgd/lazy updates generalizes trivially. To classify, pick the y with the highest β T x. The partition function has M terms. rest. 6 One of the βs is redundant. We can make one of them 0 by subtracting it from the Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 34 / 56

1 Logistic Regression (Plain and Simple) Introduction to logistic regression 2 Learning Algorithm Log-Likelihood Gradient Descent Lazy Updates 3 Kernelization 4 Sequence Tagging

Logistic Regression with Kernels As we said before, β is in the span of the examples, i.e., β = N i=1 α ix i So in order to classify a test feature vector x we compute β T x = N i=1 α ixi T x If we have a high-dimensional feature map φ(x) and learn a logistic regression model in this high-dimensional space, we will compute β T φ(x) = N i=1 α iφ(x i ) T φ(x) = N i=1 α ik(x i, x) So if we have a positive definite kernel k(.,.), we can kernelize logistic regression. e.g. Gaussian radial basis function (rbf) kernel k(x i, x) = exp( λ x i x 2 ) Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 35 / 56

Logistic Regression with Kernels For SVMs most of the α i = 0 (sparse model). For logistic regression the model is not sparse, which is a problem because Learning involves estimating all the N α i s, and classification involves computing the kernel of the test vector with all the training vectors. Training is slow, the model is very large and testing will be very slow. Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 36 / 56

Sparse Kernel Logistic Regression: Two Common Approaches Greedily select a subset of the α i to be non-zero, so the full model is best approximated by the reduced model (Import Vector Machine 7 ). Allow a random subset of α i to be non-zero and maximize the log-likelihood on the entire training data. 7 Zhu & Hastie (2001), Kernel Logistic Regression and the Import Vector Machine Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 37 / 56

Sparse Kernel Logistic Regression: Our Approach What are we doing when we pick a random subset of αs (say n of them)? We are writing β T i φ(x) = = N α i φ(x i ) T φ(x) i=1 n α i k(x i, x) = i=1 i=1 n α i z i = α T z Essentially we transformed the feature vector x into an n-dimensional feature vector z. In this transformed feature space we are doing a plain linear logistic regression. Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 38 / 56

Sparse Kernel Logistic Regression: Our Approach β T i φ(x) = = N α i φ(x i ) T φ(x) i=1 n α i k(x i, x) = i=1 i=1 n α i z i = α T z i Each coordinate in this transformed space is the kernel value of the test vector to one example in our subset. We can think of our n training feature vectors as prototypes Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 39 / 56

Sparse Kernel Logistic Regression: Our Approach There is no reason why the prototypes should be from the training data. We can pick any points in our feature space to serve as prototypes. We can even learn these prototypes. For differentiable kernels we can learn them by gradient ascent. In fact we go further and learn the kernel parameters as well (e.g. the scale parameter for the rbf kernel). Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 40 / 56

Sparse Prototype Kernel Logistic Regression Assume we have n prototypes {u 1,..., u n }. We have p(y i = y x i ; α) = exp(αt y k(x, u i )) y exp(αt y k(x, u i )) = exp(αt y z i ) y exp(αt y z i ) If the kernel is differentiable w.r.t. to u i and its parameter... we can compute the gradient of the log-likelihood log p(y = y i x i ; α) and... update both the prototypes and the kernel params by stochastic gradient ascent. Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 41 / 56

Gradient Calculation w.r.t. Prototypes u l log p(y = c x i ) = M α c T z i log( exp(αy T z i )) u l y=1 n n exp( α yj z ij )) = u l α cj z ij log( j=1 y = α cl z il n p(y x i ) u l y j=1 ( = α cl ) p(y x i )α yl y α yj u l z ij j=1 z ij u l Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 42 / 56

Gradient Calculation w.r.t. Kernel Parameter If the kernel k(.,.) is parameterized by λ, λ log p(y = c x i) = M α c T z i log( exp(αy T z i )) λ y=1 = n n α cj z ij λ log( exp( α yj z ij )) j=1 y j=1 n = α cj λ z ij n p(y x i ) α yj λ z ij j=1 y j=1 ( n = α cj ) p(y x i )α yj λ z ij y j=1 Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 43 / 56

Gradient Calculation Gaussian Radial Basis Function Kernel For the Gaussian r.b.f. kernel z il = k(x i, u l ) = exp( λ x i u l 2 ). u l z ij = u l exp( λ x i u l 2 ) = 2λ(x i u l )z il λ z ij = λ exp( λ x i u l 2 ) = x i u l 2 z il Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 44 / 56

Sparse Prototype Kernel Logistic Regression Algorithm 2: Prototype Kernel Logistic Regression Input: D = {x i, y i } i=1...n, η, MaxEpochs, Convergence Threshold β 0 Initialize prototypes and kernel param. for e = 1 : MaxEpochs Log-Likelihood Convergence do for i = 1 : N do Update β by gradient ascent. for i = 1 : N do Update prototypes by gradient ascent. for i = 1 : N do Update kernel param by gradient ascent. return β, prototypes, kernel param Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 45 / 56

Sparse Prototype Kernel Logistic Regression Done naively the updates cannot take advantage of feature vector sparsity anymore. Since our kernelization approach can be extended to any similarity function, we compute the rbf kernel value based on the distance along only the subset of features that are non-zero. That means that we need not visit the coordinates of the prototypes corresponding to non-zero feature values. We also update the prototypes lazily. For the r.b.f. kernel, the parameter update worked best when the kernel was parameterized as k(x i, u l ) = exp( exp(θ) x i u l 2 ). Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 46 / 56

Demo Here Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 47 / 56

1 Logistic Regression (Plain and Simple) Introduction to logistic regression 2 Learning Algorithm Log-Likelihood Gradient Descent Lazy Updates 3 Kernelization 4 Sequence Tagging

Non-I.I.D. Data We ve be assuming that the examples are generated i.i.d. from the distribution p(x, y). In particular our model assumes p(y 1 = a 1,..., y N = a N x 1,..., x N ) = p(y 1 = a 1 x 1 )... p(y N = a N x N ) For some problems (like Named Entity Tagging) such a model is too weak because we know that the label for an example depends on the labels for the neighboring ones. How can we incorporate dependencies among the labels into our model? In particular, say we want to model Markov dependencies. Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 48 / 56

Markov Random Field We can describe conditional independences by a Markov Random Field (MRF). An MRF is a graph over the random variables of interest such that a variable is conditionally independent of all other variables given its neighbors. The Hammersley-Clifford theorem states that the density can be written as a product of clique potentials over all maximal cliques. Clique potentials are positive functions of the random variables that comprise the clique. A Conditional Random Field is a special kind of MRF, where we are interested in dependences (between labels) conditioned on some global random vector (observations) 8. 8 Lafferty et. al. (2001), Conditional random fields: Probabilistic models for segmenting and labeling sequence data Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 49 / 56

Conditional Random Fields: Example Consider the CRF in the following example The probability that P = p(y 1 = 0, y 2 = 1, y 3 = 1, y 4 = 0 x 1, x 2, x 3, x 4 ) is given by P ψ 12 (0, 1, x) ψ 23 (1, 1, x) ψ 34 (1, 0, x) where ψ i,j (y 1, y 2, x) are the potential functions. Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 50 / 56

Conditional Random Fields: Example Consider the CRF in the following example Often we pick the same potential function ψ i,j (y 1, y 2, x) = ψ(y 1, y 2, x). Moreover, since the potential is positive ψ(y 1, y 2, x) = exp(f (y 1, y 2, x)) If f () is linear in x, ψ(y 1, y 2, x) = exp(βy T 1 y 2 x) Looks very much like a logistic regression model. How many terms does the partition function have? Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 51 / 56

Learning and Decoding for CRFs To learn CRFs by gradient descent, we need to compute the derivative of the log-likelihood. Again the derivative involves the partition function. The calculation of the partition function is efficient for chain CRFs (forward-backward algorithm). Although MALLET uses L-BFGS, CRFs can also be learned by stochastic gradient descent. For chain CRFs decoding can be done efficiently by dynamic programming (Viterbi algorithm). Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 52 / 56

Viterbi Decoding The weight on the arrows represents the benefit of transitioning from the previous label to the current label for that particular token. It is the logarithm of the potential function value for that clique (β T y 1 y 2 x). To decode, we find the path with the maximum benefit by dynamic programming. Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 53 / 56

Sequence Tagging without CRFs We can use Viterbi decoding without the additional cost of forward-backward at training time by just learning a logistic regression to pairs of classes. The training sequence data is used to assign a class-pair label to each example. The class-pair model is smoothed with a single class model. At decoding time pretend that the model was learned under a CRF assumption. Often gives a better model because the assumption made by CRFs that the training sequences are drawn i.i.d. is violated. Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 54 / 56

Sequence Tagging using Logistic Regression Our approach gives similar (and sometimes better) accuracy for NER than CRFs (MALLET). Our un-optimized implementation trains 30-50 times faster. The code is being used in projects requiring incremental learning. The barrier for implementing active learning systems is now much lower. Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 55 / 56

Current and Near Term Minimax & Type-specific Priors for domain independence. Active Learning Ranking Semi-Supervised... Harsha Veeramachaneni (TR R&D) Logistic Regression April 1, 2010 56 / 56