Docsity

Variable Selection and Model Verification – Introduction to Machine Learning | CSI 5V93, Study notes of Software Engineering

Partial preview of the text

Download Variable Selection and Model Verification – Introduction to Machine Learning | CSI 5V93 and more Study notes Software Engineering in PDF only on Docsity!

Lecture 8: Variable selection and model verification

CSI 5v93: Introduction to machine learning

Baylor University

Computer Science Department

Dr. Greg Hamerly

http://cs.baylor.edu/˜hamerly/

CSI 5v93: Introduction to machine learning, Lecture 8 – p. 1/

Announcements

Homework 2 due February 8th

Questions?

Questions from last time:

statistic? – F statistic instead of the t For stepwise selection, why not use the

see homework, exercise 3.

More examples – coming as we move along

How do we choose the best model using ridge regression?

How do we use ridge regression?

What is cross-validation? How does it work?

How can correlated variables negate one another?

CSI 5v93: Introduction to machine learning, Lecture 8 – p. 3/

Chapter 3: Linear methods for regression

3.1 – Introduction

3.2 – Linear regression models and least squares

3.3 – Multiple regression from simple univariate regression

3.4 – Subset selection and coefficient shrinkage

3.5 – Computational considerations

The problem of correlated variables

β = y Let

1

x

1

β +

2

x

2

be our model

x If

1 x and

2 β are independent, then both

1 β and

2 .y are necessary to represent

x If

1 x =

2 x , or

1 x is some multiple of

2

. correlated , then they are

β If they’re correlated, then EITHER

1 β or

2 .y could be used to accurately represent

β The

1 β and

2 are not unique. This causes instability.

X to the diagonal of λ Ridge regression solves this by adding

T

. X

CSI 5v93: Introduction to machine learning, Lecture 8 – p. 7/

Example of ridge regression

Coefficients

8 6 4 2 0

-0.

                    • - - - - - - - - - - - - - - -

lcavol

    • ••

      - - - - - - - - - - - - - - - - - - - - 

lweight

                    • - - - - - - - - - •••• - -

age

    • ••

      - • - - - - - - - - - - - - - - - - - - 

lbph

                    • - - - - - - - - - - - - - - -

svi

                    • - - - - - - • - • - - - - - -

lcp

              • •

                - - - • - • • - • - • - • - - - 

gleason

                    • - - - - - - - - - - - - - - -

pgg









Model selection

How do we choose the best model for a machine learning problem?

for that model. parameters and the type means choosing the model Choosing a model

There are different model types:

linear regression

k-nearest neighbor

many others we will look at

There are different parameters that we can select:

use all parameters

use a subset (subset selection)

shrink the coefficients

create new parameters as combinations of the old ones

other ways to select parameters...

CSI 5v93: Introduction to machine learning, Lecture 8 – p. 9/

Determining the best model

How do we determine which of two models is better?

accuracy often we use some measure of the model’s

There are lots of possibilities:

sum-of-squared error (aka RSS, for regression problems)

sum of absolute error (for regression problems)

prediction accuracy (for classification problems)

likelihood

other?

All of these metrics could be measured on:

the training set

the test set

a holdout validation set

other?

Cross-validation

Cross-validation takes the hold-out set one step further.

disjoint parts (aka folds): k into X Divide your training data

X = X

1

X ∪

2

X ∪... ∪

k

Cross validation procedure:

:... k = 1 i loop over

X − X{ train on

i }

X validate on

i X (obtain an accuracy or error on

i )

errors k report the

(10-fold = 10 k (called leave-one-out cross validation), or n = k It’s common to use

cross validation)

CSI 5v93: Introduction to machine learning, Lecture 8 – p. 13/

Cross validation and choosing the model

for each model. folds k different errors on the k Cross validation produces

Taking the average of the errors will give an idea of the expected error for other similar

test sets.

Finding the standard deviation of the errors gives an idea of how much the model

varies in its error.

Examples of variable selection

Subset Size

CV Error

8 6 4 2 0

All Subsets

Degrees of Freedom

CV Error

8 6 4 2 0

Ridge Regression

Shrinkage Factor s

CV Error

1.0 0.8 0.6 0.4 0.2 0.

Lasso

Number of Directions

CV Error

8 6 4 2 0

Principal Components Regression

Number of Directions

CV Error

8 6 4 2 0

Partial Least Squares

Error bars are obtained by cross-validation.

The least complex model within 1 standard error of the best average error is chosen.

CSI 5v93: Introduction to machine learning, Lecture 8 – p. 15/

Cross validation, nearest neighbors, and repeats

Think about the 1-nearest neighbor classifier.

Imagine that your training data has 2 copies of every input example.

What if you use leave-one-out cross validation with this model and data?