7
6. Linear & logisc regressions Foundaons of Machine Learning CentraleSupélec — Fall 2017 Chloé-Agathe Azencot Centre for Computaonal Biology, Mines ParisTech [email protected] Learning objecves Density esmaon: Define parametric methods. Define the maximum likelihood esmator and compute it for Bernouilli, mulnomial and Gaussian densies. Define the Bayes esmator and compute it for normal priors. Supervised learning: Compute the maximum likelihood esmator / least- square fit soluon for linear regression. Compute the maximum likelihood esmator for logisc regression. Parametric methods Parametric esmaon: assume a form for p(x|θ) E.g. Goal: esmate θ using X usually assume that independent and idencally distributed (iid) Density esmaon

iml chap6 linreg handout - Chloé-Agathe Azencottcazencott.info/.../handouts/iml_chap6_handout.pdfCentre for Computational Biology, Mines ParisTech [email protected]

Embed Size (px)

Citation preview

6. Linear & logistic regressions

Foundations of Machine LearningCentraleSupélec — Fall 2017

Chloé-Agathe AzencotCentre for Computational Biology, Mines ParisTech

[email protected]

6. Linear & logistic regressions

Foundations of Machine LearningCentraleSupélec — Fall 2017

Chloé-Agathe AzencotCentre for Computational Biology, Mines ParisTech

[email protected]

Learning objectives● Density estimation:

– Define parametric methods.– Define the maximum likelihood estimator and compute

it for Bernouilli, multinomial and Gaussian densities.– Define the Bayes estimator and compute it for normal

priors.● Supervised learning:

– Compute the maximum likelihood estimator / least-square fit solution for linear regression.

– Compute the maximum likelihood estimator for logistic regression.

Learning objectives● Density estimation:

– Define parametric methods.– Define the maximum likelihood estimator and compute

it for Bernouilli, multinomial and Gaussian densities.– Define the Bayes estimator and compute it for normal

priors.● Supervised learning:

– Compute the maximum likelihood estimator / least-square fit solution for linear regression.

– Compute the maximum likelihood estimator for logistic regression.

Parametric methods●

● Parametric estimation:– assume a form for p(x|θ)

E.g.

– Goal: estimate θ using X– usually assume that independent and identically

distributed (iid)

Density estimation

Parametric methods●

● Parametric estimation:– assume a form for p(x|θ)

E.g.

– Goal: estimate θ using X– usually assume that independent and identically

distributed (iid)

Density estimation

Maximum likelihood estimation

● Find θ such that X is the most likely to be drawn.● Likelihood of θ given the i.i.d. sample X:

● Log likelihood:

● Maximum likelihood estimation (MLE):

Maximum likelihood estimation● Find θ such that X is the most likely to be drawn.● Likelihood of θ given the i.i.d. sample X:

● Log likelihood:

● Maximum likelihood estimation (MLE):

Bernouilli density● Two states: failure / success

● MLE estimate of p0 ?

Bernouilli density● Two states: failure / success

● MLE estimate of p0 ?

Multinomial density● Consider K mutually exclusive and exhaustive

classes– Each class occurs with probability pk

– x1, x2, …, xK indicator variables: x1=1 if the outcome is class k and 0 otherwise

● The MLE of pk is

Multinomial density● Consider K mutually exclusive and exhaustive

classes– Each class occurs with probability pk

– x1, x2, …, xK indicator variables: x1=1 if the outcome is class k and 0 otherwise

● The MLE of pk is

Gaussian distribution● Gaussian distribution = normal distribution

MLE estimates of μ and σ:?

Gaussian distribution● Gaussian distribution = normal distribution

MLE estimates of μ and σ:?

Bias-variance tradeof● Mean squared error of the estimator:

A biased estimator may achieve better MSE than an unbiased one.

θθ0E[θθ̂]

bias

variance

Bias-variance tradeof● Mean squared error of the estimator:

A biased estimator may achieve better MSE than an unbiased one.

θθ0E[θθ̂]

bias

variance

Bayes estimator● Treat θ as a random variable with prior p(θ)● Bayes rule: ● Density estimation

● Maximum likelihood estimate (MLE):

● Bayes estimate:

Bayes estimator● Treat θ as a random variable with prior p(θ)● Bayes rule: ● Density estimation

● Maximum likelihood estimate (MLE):

● Bayes estimate:

● n data points (iid) ● MLE of θ:

Bayes estimator of θ:

Bayes estimator: Normal prior

?

● n data points (iid) ● MLE of θ:

Bayes estimator of θ:

Bayes estimator: Normal prior

?

Linear regression

Linear regression

Linear regression: MLE● Assume error is Gaussian distributed

● Replace g with its estimator f

xx*

E[y|x*]

E[y|x] = βx+β0

p(y|x*)

Linear regression: MLE● Assume error is Gaussian distributed

● Replace g with its estimator f

xx*

E[y|x*]

E[y|x] = βx+β0

p(y|x*)

Gauss-Markov Theorem● Under the assumption that

the least-squares estimator of β is its (unique) best linear unbiased estimator.

● Best Linear Unbiased Estimator (BLUE):Var(βθ̂) < Var(β*) for any β* that is a linear unbiased estimator of β

psd and minimal for D=0

Gauss-Markov Theorem● Under the assumption that

the least-squares estimator of β is its (unique) best linear unbiased estimator.

● Best Linear Unbiased Estimator (BLUE):Var(βθ̂) < Var(β*) for any β* that is a linear unbiased estimator of β

psd and minimal for D=0

Correlated variables● If the variables are decorrelated:

– Each coefficient can be estimated separately;– Interpretation is easy:

“A change of 1 in x j is associated with a change of βj in Y, while everything else stays the same.”

● Correlations between variables cause problems:– The variance of all coefficients tend to increase;– Interpretation is much harder

when xj changes, so does everything else.

Correlated variables● If the variables are decorrelated:

– Each coefficient can be estimated separately;– Interpretation is easy:

“A change of 1 in x j is associated with a change of βj in Y, while everything else stays the same.”

● Correlations between variables cause problems:– The variance of all coefficients tend to increase;– Interpretation is much harder

when xj changes, so does everything else.

What about classification?● Model Pr(Y=1|X) as a linear function? ?

Logistic regression

What about classification?● Model Pr(Y=1|X) as a linear function? ?

Logistic regression

Maximum likelihood estimation of logistic regression coefficients

● Log likelihood for n observations:

● Gradient of the log likelihood:

Maximum likelihood estimation of logistic regression coefficients

● Log likelihood for n observations:

● Gradient of the log likelihood:

Summary● MAP estimate:

● MLE:

● Bayes estimate:

● Assuming Gaussian error, maximizing the likelihood is equivalent to minimizing the RSS.

● Linear regression MLE:

● Logistic regression MLE: solve with gradient descent.

Summary● MAP estimate:

● MLE:

● Bayes estimate:

● Assuming Gaussian error, maximizing the likelihood is equivalent to minimizing the RSS.

● Linear regression MLE:

● Logistic regression MLE: solve with gradient descent.

References● A Course in Machine Learning. http://ciml.info/dl/v0_99/ciml-v0_99-all.pdf

– Least-squares regression: Chap 7.6● The Elements of Statistical Learning. http://web.stanford.edu/~hastie/ElemStatLearn/

– Least-squares regression: Chap 2.2.1, 3.1, 3.2.1– Gauss-Markov theorem: Chap 3.2.3

References● A Course in Machine Learning. http://ciml.info/dl/v0_99/ciml-v0_99-all.pdf

– Least-squares regression: Chap 7.6● The Elements of Statistical Learning. http://web.stanford.edu/~hastie/ElemStatLearn/

– Least-squares regression: Chap 2.2.1, 3.1, 3.2.1– Gauss-Markov theorem: Chap 3.2.3