Modern Trends in Data Mining - Stanford Universityhastie/TALKS/ISI09_trends.pdfAug 05, 2009  ·...

44
Modern Trends in Data Mining Trevor Hastie Stanford University August 2009.

Transcript of Modern Trends in Data Mining - Stanford Universityhastie/TALKS/ISI09_trends.pdfAug 05, 2009  ·...

Page 1: Modern Trends in Data Mining - Stanford Universityhastie/TALKS/ISI09_trends.pdfAug 05, 2009  · Data Mining Trevor Hastie, Stanford University 7 Netflix Challenge Netflix users

Modern Trends in Data Mining

Trevor Hastie

Stanford University

August 2009.

• •

•••

•••

••

• •

••

••

• • ••

•••

••

••

••

••

•• •

Page 2: Modern Trends in Data Mining - Stanford Universityhastie/TALKS/ISI09_trends.pdfAug 05, 2009  · Data Mining Trevor Hastie, Stanford University 7 Netflix Challenge Netflix users

Data Mining Trevor Hastie, Stanford University 2

Enlarge This Image

Thor Swift for The New York Times

Carrie Grimes, senior staff engineer at

Google, uses statistical analysis of

data to help improve the company's

search engine.

Multimedia

For Today’s Graduate, Just One Word: StatisticsBy STEVE LOHR

Published: August 5, 2009

MOUNTAIN VIEW, Calif. — At Harvard, Carrie Grimes majored in

anthropology and archaeology and ventured to places like Honduras,

where she studied Mayan settlement patterns by mapping where

artifacts were found. But she was drawn to what she calls “all the

computer and math stuff” that was part of the job.

“People think of field archaeology as

Indiana Jones, but much of what you

really do is data analysis,” she said.

Now Ms. Grimes does a different kind

of digging. She works at Google,

where she uses statistical analysis of mounds of data to

come up with ways to improve its search engine.

Ms. Grimes is an Internet-age statistician, one of many

who are changing the image of the profession as a place for

dronish number nerds. They are finding themselves

increasingly in demand — and even cool.

“I keep saying that the sexy job in the next 10 years will be

statisticians,” said Hal Varian, chief economist at Google.

“And I’m not kidding.”

Next Article in Technology (1 of 20) »

Subscribe to Technology RSS Feeds

SIGN IN TO

RECOMMEND

SIGN IN TO

E-MAIL

PRINT

REPRINTS

SHARE

Quote of the Day,

New York Times,

August 5, 2009

”I keep saying that the sexy

job in the next 10 years

will be statisticians. And

I’m not kidding.” - HAL

VARIAN, chief economist

at Google.

Page 3: Modern Trends in Data Mining - Stanford Universityhastie/TALKS/ISI09_trends.pdfAug 05, 2009  · Data Mining Trevor Hastie, Stanford University 7 Netflix Challenge Netflix users

Data Mining Trevor Hastie, Stanford University 3

Datamining for Prediction

• We have a collection of data pertaining to our business,

industry, production process, monitoring device, etc.

• Often the goals of data-mining are vague, such as “look for

patterns in the data” — not too helpful.

• In many cases a “response” or “outcome” can be identified as a

good and useful target for prediction.

• Accurate prediction of this target can help the organization

make better decisions, and save time and money.

• Data-mining is particularly good at building such prediction

models — an area known as ”supervised learning”.

Page 4: Modern Trends in Data Mining - Stanford Universityhastie/TALKS/ISI09_trends.pdfAug 05, 2009  · Data Mining Trevor Hastie, Stanford University 7 Netflix Challenge Netflix users

Data Mining Trevor Hastie, Stanford University 4

Example: Credit Risk Assessment

• Customers apply to a bank for a loan or credit card.

• They supply the bank with information such as age, income,

employment history, education, bank accounts, existing debts,

etc.

• The bank does further background checks to establish credit

history of customer.

• Based on this information, the bank must decide whether to

make the loan or issue the credit card.

Page 5: Modern Trends in Data Mining - Stanford Universityhastie/TALKS/ISI09_trends.pdfAug 05, 2009  · Data Mining Trevor Hastie, Stanford University 7 Netflix Challenge Netflix users

Data Mining Trevor Hastie, Stanford University 5

Example continued: Credit Risk Assessment

• The bank has a large database of existing and past customers.

Some of these defaulted on loans, others frequently made late

payments etc. An outcome variable “Status” is defined, taking

value “good” or “defaulted”. Each of the past customers is

scored with a value for status.

• Background information is available for all the past customers.

• Using supervised learning techniques, we can build a risk

prediction model that takes as input the background

information, and outputs a risk estimate (probability of

default) for a prospective customer.

The California based company Fair-Isaac uses a generalized

additive model + boosting methods in the construction of their

credit risk scores.

Page 6: Modern Trends in Data Mining - Stanford Universityhastie/TALKS/ISI09_trends.pdfAug 05, 2009  · Data Mining Trevor Hastie, Stanford University 7 Netflix Challenge Netflix users

Data Mining Trevor Hastie, Stanford University 6

Grand Prize: one million dollars, if beat Netflix’s RMSE by 10%.

Competition ends after ≈ 3 years, two leaders, 41305 teams!

Page 7: Modern Trends in Data Mining - Stanford Universityhastie/TALKS/ISI09_trends.pdfAug 05, 2009  · Data Mining Trevor Hastie, Stanford University 7 Netflix Challenge Netflix users

Data Mining Trevor Hastie, Stanford University 7

Netflix Challenge

Netflix users rate movies from 1-5. Based on a history of ratings,

predict the rating a viewer will give to a new movie.

• Training data: sparse 400K (users) by 18K (movies) rating

matrix, with 98.7% missing. About 100M movie/rater pairs.

• Quiz set of about 1.4M movie/viewer pairs, for which

predictions of ratings are required (Netflix has held them back)

• Probe set of about 1.4 million movie/rater pairs similar in

composition to the quiz set, for which the ratings are known.

• Both winning teams used ensemble methods to achieve their

results.

Page 8: Modern Trends in Data Mining - Stanford Universityhastie/TALKS/ISI09_trends.pdfAug 05, 2009  · Data Mining Trevor Hastie, Stanford University 7 Netflix Challenge Netflix users

Data Mining Trevor Hastie, Stanford University 8

The Supervised Learning Problem

Starting point:

• Outcome measurement Y (also called dependent variable,

response, target, output)

• Vector of p predictor measurements X (also called inputs,

regressors, covariates, features, independent variables)

• In the regression problem, Y is quantitative (e.g price, blood

pressure, rating)

• In classification, Y takes values in a finite, unordered set

(default yes/no, churn/retain, spam/email)

• We have training data (x1, y1), . . . , (xN , yN ). These are

observations (examples, instances) of these measurements.

Page 9: Modern Trends in Data Mining - Stanford Universityhastie/TALKS/ISI09_trends.pdfAug 05, 2009  · Data Mining Trevor Hastie, Stanford University 7 Netflix Challenge Netflix users

Data Mining Trevor Hastie, Stanford University 9

Objectives

On the basis of the training data we would like to:

• Accurately predict unseen test cases for which we know X but

do not know Y .

• In the case of classification, predict the probability of an

outcome.

• Understand which inputs affect the outcome, and how.

• Assess the quality of our predictions and inferences.

Page 10: Modern Trends in Data Mining - Stanford Universityhastie/TALKS/ISI09_trends.pdfAug 05, 2009  · Data Mining Trevor Hastie, Stanford University 7 Netflix Challenge Netflix users

Data Mining Trevor Hastie, Stanford University 10

More Examples

• Determine whether an incoming email is “spam”, based on

frequencies of key words in the message

• Identify the numbers in a handwritten zip code, from a

digitized image

• Estimate the probability that an insurance claim is fraudulent,

based on client demographics, client history, and the amount

and nature of the claim.

• Predict the type of cancer in a tissue sample using DNA

expression values, and more imprtantly, identify the relevant

genes.

• Model the prevalence of disease as a function of genotype

information at a small subset of 500K SNPs measured from a

DNA sample, and thereby identify the relevant SNPs.

Page 11: Modern Trends in Data Mining - Stanford Universityhastie/TALKS/ISI09_trends.pdfAug 05, 2009  · Data Mining Trevor Hastie, Stanford University 7 Netflix Challenge Netflix users

Data Mining Trevor Hastie, Stanford University 11

Email or Spam?

• data from 4601 emails sent to an individual (named George, at

HP labs, before 2000). Each is labeled as “spam” or “email”.

• goal: build a customized spam filter.

• input features: relative frequencies of 57 of the most commonly

occurring words and punctuation marks in these email

messages.

george you hp free ! edu remove

spam 0.00 2.26 0.02 0.52 0.51 0.01 0.28

email 1.27 1.27 0.90 0.07 0.11 0.29 0.01

Average percentage of words or characters in an email message equal to

the indicated word or character. We have chosen the words and

characters showing the largest difference between spam and email.

Page 12: Modern Trends in Data Mining - Stanford Universityhastie/TALKS/ISI09_trends.pdfAug 05, 2009  · Data Mining Trevor Hastie, Stanford University 7 Netflix Challenge Netflix users

Data Mining Trevor Hastie, Stanford University 12

Handwritten Digit Identification

A sample of segmented and normalized handwritten digits, scanned

from zip-codes on envelopes. Each image has 16 × 16 pixels of

greyscale values ranging from 0 − 255.

Page 13: Modern Trends in Data Mining - Stanford Universityhastie/TALKS/ISI09_trends.pdfAug 05, 2009  · Data Mining Trevor Hastie, Stanford University 7 Netflix Challenge Netflix users

Data Mining Trevor Hastie, Stanford University 13

SID42354SID31984

SID301902SIDW128368SID375990SID360097

SIDW325120ESTsChr.10SIDW365099SID377133SID381508

SIDW308182SID380265

SIDW321925ESTsChr.15SIDW362471SIDW417270SIDW298052SID381079

SIDW428642TUPLE1TUP1

ERLUMENSIDW416621

SID43609ESTs

SID52979SIDW357197SIDW366311

ESTsSMALLNUCSIDW486740

ESTsSID297905SID485148SID284853ESTsChr.15SID200394

SIDW322806ESTsChr.2

SIDW257915SID46536

SIDW488221ESTsChr.5SID280066

SIDW376394ESTsChr.15SIDW321854WASWiskott

HYPOTHETICALSIDW376776SIDW205716SID239012

SIDW203464HLACLASSISIDW510534SIDW279664SIDW201620SID297117SID377419SID114241ESTsCh31

SIDW376928SIDW310141SIDW298203

PTPRCSID289414SID127504ESTsChr.3SID305167SID488017

SIDW296310ESTsChr.6SID47116

MITOCHONDRIAL60Chr

SIDW376586HomosapiensSIDW487261SIDW470459SID167117SIDW31489SID375812

DNAPOLYMERSID377451ESTsChr.1

MYBPROTOSID471915

ESTsSIDW469884HumanmRNASIDW377402

ESTsSID207172

RASGTPASESID325394

H.sapiensmRNAGNAL

SID73161SIDW380102SIDW299104

BR

EA

ST

RE

NA

LR

EN

AL

RE

NA

LP

RO

ST

AT

EN

SC

LCO

VA

RIA

NC

NS

BR

EA

ST

NS

CLC

MC

F7A

-rep

roO

VA

RIA

NO

VA

RIA

NC

OLO

NB

RE

AS

TN

SC

LCLE

UK

EM

IAM

ELA

NO

MA

CN

SC

OLO

NP

RO

ST

AT

ELE

UK

EM

IAN

SC

LCN

SC

LCC

NS

CN

SM

CF

7D-r

epro

ME

LAN

OM

AB

RE

AS

TR

EN

AL

RE

NA

LO

VA

RIA

NLE

UK

EM

IAB

RE

AS

TM

ELA

NO

MA

LEU

KE

MIA

RE

NA

LB

RE

AS

TM

ELA

NO

MA

LEU

KE

MIA

ME

LAN

OM

AC

OLO

NN

SC

LCC

OLO

NO

VA

RIA

NN

SC

LCK

562A

-rep

roLE

UK

EM

IAC

OLO

NN

SC

LCO

VA

RIA

NK

562B

-rep

roC

NS

RE

NA

LC

OLO

NM

ELA

NO

MA

NS

CLC

RE

NA

LU

NK

NO

WN

ME

LAN

OM

AM

ELA

NO

MA

BR

EA

ST

CO

LON

RE

NA

L

Microarray Cancer Data

Expression matrix of 6830 genes

(rows) and 64 samples (columns),

for the human tumor data (100

randomly chosen rows shown).

The display is a heat map, rang-

ing from bright green (under ex-

pressed) to bright red (over ex-

pressed).

Goal: identify which genes are

over/under expressed in different

cancer classes. Prediction mod-

els are a vehicle for achieving this

goal.

Page 14: Modern Trends in Data Mining - Stanford Universityhastie/TALKS/ISI09_trends.pdfAug 05, 2009  · Data Mining Trevor Hastie, Stanford University 7 Netflix Challenge Netflix users

Data Mining Trevor Hastie, Stanford University 14

Shameless self-promotion

All but the last of the topics in

this lecture are covered in the 2009

second edition of our 2001 book.

The book blends traditional linear

methods with contemporary non-

parametric methods, and many

between the two.

Page 15: Modern Trends in Data Mining - Stanford Universityhastie/TALKS/ISI09_trends.pdfAug 05, 2009  · Data Mining Trevor Hastie, Stanford University 7 Netflix Challenge Netflix users

Data Mining Trevor Hastie, Stanford University 15

Ideal Predictions

• For a quantitative output Y , the best prediction we can make

when the input vector X = x is

f(x) = Ave(Y |X = x)

– This is the conditional expectation — deliver the Y -average

of all those examples having X = x.

– This is best if we measure errors by average squared error

Ave(Y − f(X))2.

• For a qualitative output Y taking values 1, 2,. . . , M , compute

– Pr(Y = m|X = x) for each value of m. This is the

conditional probability of class m at X = x.

– Classify C(x) = j if Pr(Y = j|X = x) is the largest — the

majority vote classifier.

Page 16: Modern Trends in Data Mining - Stanford Universityhastie/TALKS/ISI09_trends.pdfAug 05, 2009  · Data Mining Trevor Hastie, Stanford University 7 Netflix Challenge Netflix users

Data Mining Trevor Hastie, Stanford University 16

Implementation with Training Data

The ideal prediction formulas suggest a data implementation. To

predict at X = x, gather all the training pairs (xi, yi) having

xi = x, then:

• For regression, use the mean of their yi to estimate

f(x) = Ave(Y |X = x)

• For classification, compute the relative proportions of each

class among these yi, to estimate Pr(Y = m|X = x); Classify

the new observation by majority vote.

Problem: in the training data, there may be NO observations

having xi = x.

Page 17: Modern Trends in Data Mining - Stanford Universityhastie/TALKS/ISI09_trends.pdfAug 05, 2009  · Data Mining Trevor Hastie, Stanford University 7 Netflix Challenge Netflix users

Data Mining Trevor Hastie, Stanford University 17

Nearest Neighbor Averaging

• Estimate Ave(Y |X = x) by

Averaging those yi whose xi are in a neighborhood of x.

• E.g. define the neighborhood to be the set of k observations

having values xi closest to x in euclidean distance ||xi − x||.

• For classification, compute the class proportions among these k

closest points.

• Nearest neighbor methods often outperform all other methods

— about one in three times — especially for classification.

Page 18: Modern Trends in Data Mining - Stanford Universityhastie/TALKS/ISI09_trends.pdfAug 05, 2009  · Data Mining Trevor Hastie, Stanford University 7 Netflix Challenge Netflix users

Data Mining Trevor Hastie, Stanford University 18

0.0 0.2 0.4 0.6 0.8 1.0

-1.5

-1.0

-0.5

0.0

0.5

1.0

1.5

O

OO

O

O

O

O

O

O

O

O

O

O

O

O

O

OOO

O

O

O

O O

O

OOO

OOOOO

O

O

O

OO

O

O

O

OO

O

OO

O

OOOO

O

O

O

O

O

OOO

O

O

O

O

O

O

O

OO

OO

O

OOOOO

O

O

O

O

O

OO

O

O

O

OO

O

OO

O

O

O

O

OOO

O

O

O

O

OOO

OOOOO

O

O

O

OO

O

O

O

OO

O

OO

O

OOOO

O

O

O

O

O

OOO

O

O

O

O

O

O

O

OO

Kernel smoothing

• Smooth version of nearest-

neighbor averaging

• At each point x, the function

f(x) = Y (Y |X = x) is esti-

mated by the weighted aver-

age of the y’s.

• The weights die down

smoothly with distance from

the target point x (indicated

by shaded orange region).

Page 19: Modern Trends in Data Mining - Stanford Universityhastie/TALKS/ISI09_trends.pdfAug 05, 2009  · Data Mining Trevor Hastie, Stanford University 7 Netflix Challenge Netflix users

Data Mining Trevor Hastie, Stanford University 19

Structured Models

• When we have a lot of predictor variables, NN methods often

fail because of the curse of dimensionality:

It is hard to find nearby points in high dimensions!

• Near-neighbor models offer little interpretation.

• We can overcome these problems by assuming some structure

for the regression function Ave(Y |X = x) or the probability

function Pr(Y = k|X = x). Typical structural assumptions:

– Linear Models

– Additive Models

– Low-order interaction models

– Restrict attention to a subset of predictors

– . . . and many more

Page 20: Modern Trends in Data Mining - Stanford Universityhastie/TALKS/ISI09_trends.pdfAug 05, 2009  · Data Mining Trevor Hastie, Stanford University 7 Netflix Challenge Netflix users

Data Mining Trevor Hastie, Stanford University 20

Linear Models

• Linear models assume

Ave(Y |X = x) = β0 + β1x1 + β2x2 + . . . + βpxp

• For two class classification problems, linear logistic regression

has the form

logPr(Y = +1|X = x)

Pr(Y = −1|X = x)= β0 + β1x1 + β2x2 + . . . + βpxp

• This translates to

Pr(Y = +1|X = x) =eβ0+β1x1+β2x2+...+βpxp

1 + eβ0+β1x1+β2x2+...+βpxp

In many of the genomic and web-era problems, we fit linear models

with potentially many 1000s of input features.

Page 21: Modern Trends in Data Mining - Stanford Universityhastie/TALKS/ISI09_trends.pdfAug 05, 2009  · Data Mining Trevor Hastie, Stanford University 7 Netflix Challenge Netflix users

Data Mining Trevor Hastie, Stanford University 21

Linear Model Complexity Control

With many input features, linear regression will overfit the training

data, leading to poor predictions on future data. Two general

remedies are available:

• Variable selection: reduce the number of inputs in the model.

For example, forward stepwise selection has regained

popularity.

• Regularization: leave all the variables in the model, but when

fitting the model, restrict their coefficients.

– Ridge:∑p

j=1 β2j ≤ s. All the coefficients are non-zero, but

are shrunk toward zero (and each other).

– Lasso:∑p

j=1 |βj | ≤ s. Some coefficients drop out the model,

others are shrink toward zero.

Page 22: Modern Trends in Data Mining - Stanford Universityhastie/TALKS/ISI09_trends.pdfAug 05, 2009  · Data Mining Trevor Hastie, Stanford University 7 Netflix Challenge Netflix users

Data Mining Trevor Hastie, Stanford University 22

Ridge

0 2 4 6 8

−0.

20.

00.

20.

40.

6

••••

••

••

••

••

••

••

••

••

•••

lcavol

••••••••••••••••••••••••

lweight

••••••••••••••••••••••••

age

•••••••••••••••••••••••••

lbph

••••••••••••••••••••••••

svi

•••

••

••

••

••

••••••••••••

lcp

••••••••••••••••••••••••

•gleason

•••••••••••••••••••••••

pgg45

Shrinkage Bound s

Coeffi

cien

tsβ(s

)

Lasso

0.0 0.2 0.4 0.6 0.8 1.0−

0.2

0.0

0.2

0.4

0.6

lcavol

lweight

age

lbph

svi

lcp

gleason

pgg45

Shrinkage Bound s

Coeffi

cien

tsβ(s

)

Both ridge and lasso coefficients paths can be computed very

efficiently for all values of s.

Page 23: Modern Trends in Data Mining - Stanford Universityhastie/TALKS/ISI09_trends.pdfAug 05, 2009  · Data Mining Trevor Hastie, Stanford University 7 Netflix Challenge Netflix users

Data Mining Trevor Hastie, Stanford University 23

Overfitting and Model Assessment

• In all cases above, the larger s, the better we will fit the

training data. Often we overfit the training data.

• Overfit models can perform poorly on test data (high variance).

• Underfit models can perform poorly on test data (high bias).

Model assessment aims to

1. Choose a value for a tuning parameter s for a technique.

2. Estimate the future prediction ability of the chosen model.

• For both of these purposes, the best approach is to evaluate the

procedure on an independent test set, if one is available.

• If possible one should use different test data for (1) and (2)

above: a validation set for (1) and a test set for (2)

Page 24: Modern Trends in Data Mining - Stanford Universityhastie/TALKS/ISI09_trends.pdfAug 05, 2009  · Data Mining Trevor Hastie, Stanford University 7 Netflix Challenge Netflix users

Data Mining Trevor Hastie, Stanford University 24

K-Fold Cross-Validation

Primarily a method for estimating a tuning parameter s when data

is scarce; we illustrate for the regularized linear regression models.

• Divide the data into K roughly equal parts (5 or 10)

Train Train Train

5

TrainTest

21 3 4

• for each k = 1, 2, . . .K, fit the model with parameter s to the

other K − 1 parts, giving β−k(s) and compute its error in

predicting the kth part: Ek(λ) =∑

i∈kth part(yi − xiβ−k(s))2.

• This gives the overall cross-validation error

CV (s) = 1K

∑Kk=1 Ek(s)

• do this for many values of s and choose the value of s that

makes CV (s) smallest.

Page 25: Modern Trends in Data Mining - Stanford Universityhastie/TALKS/ISI09_trends.pdfAug 05, 2009  · Data Mining Trevor Hastie, Stanford University 7 Netflix Challenge Netflix users

Data Mining Trevor Hastie, Stanford University 25

Cross-Validation Error Curve

0.0 0.2 0.4 0.6 0.8 1.0

3000

3500

4000

4500

5000

5500

6000

Tuning Parameter s

CV

Err

or

• 10-fold CV error curve using

lasso on some diabetes data

(64 inputs, 442 samples).

• Thick curve is CV error curve

• Shaded region indicates stan-

dard error of CV estimate.

• Curve shows effect of over-

fitting — errors start to in-

crease above s = 0.2.

• This shows a trade-off be-

tween bias and variance.

Page 26: Modern Trends in Data Mining - Stanford Universityhastie/TALKS/ISI09_trends.pdfAug 05, 2009  · Data Mining Trevor Hastie, Stanford University 7 Netflix Challenge Netflix users

Data Mining Trevor Hastie, Stanford University 26

Modern Structured Models in Data Mining

The following is a list of some of the currently popular prediction

models in data mining.

• Linear models with lasso or related regularization

• Generalized additive models/ naive Bayes — simple but

effective.

• Neural networks — somewhat old but still used a lot.

• Trees, random forests and boosted tree models.

• Support vector and kernel machines.

• Matrix completion methods.

Page 27: Modern Trends in Data Mining - Stanford Universityhastie/TALKS/ISI09_trends.pdfAug 05, 2009  · Data Mining Trevor Hastie, Stanford University 7 Netflix Challenge Netflix users

Data Mining Trevor Hastie, Stanford University 27

Generalized Additive Models

Allow a compromise between linear models and more flexible local

models (kernel estimates) when there are a many inputs

X = (X1, X2, . . . , Xp).

• Additive models for regression:

Ave(Y |X = x) = α0 + f1(x1) + f2(x2) + . . . + fp(xp).

• Additive models for classification:

logPr(Y = +1|X = x)

Pr(Y = −1|X = x)= α0 + f1(x1) + f2(x2) + . . . + fp(xp).

Close relative of naive Bayes model.

Each of the functions fj(xj) (one for each input variable), can be a

smooth function (ala kernel estimate), linear, or omitted.

Page 28: Modern Trends in Data Mining - Stanford Universityhastie/TALKS/ISI09_trends.pdfAug 05, 2009  · Data Mining Trevor Hastie, Stanford University 7 Netflix Challenge Netflix users

Data Mining Trevor Hastie, Stanford University 28

0 2 4 6 8

-50

5

0 1 2 3

-50

5

0 2 4 6

-50

510

0 2 4 6 8 10

-50

510

0 2 4 6 8 10

-50

510

0 2 4 6

-50

510

0 5 10 15 20

-10

-50

0 5 10

-10

-50

0 10 20 30

-10

-50

5

0 2 4 6

-50

5

0 5 10 15 20

-10

-50

5

0 5 10 15

-10

-50

0 10 20 30

-50

510

0 1 2 3 4 5 6

-50

510

0 2000 6000 10000

-50

5

0 5000 10000 15000

-50

5

our over remove internet

free business hp hpl

george 1999 re edu

ch! ch$ CAPMAX CAPTOT

f(our)

f(over)

f(remove)

f(internet)

f(free)

f(business)

f(hp)

f(hpl)

f(george)

f(1999)

f(re)

f(edu)

f(ch!)

f(ch$)

f(CAPMAX)

f(CAPTOT)

FIGURE 9.1. Spam analysis: estimated functions for significant predictors. The

GAM fit to SPAM data

• Shown are the most important

predictors.

• Many show nonlinear behav-

ior.

• Overall error rate 5.3% .

• Functions can be re-

parametrized (e.g. log terms,

quadratic, step-functions),

and then fit by linear model.

• Produces a prediction per

email Pr(spam|X = x)

Page 29: Modern Trends in Data Mining - Stanford Universityhastie/TALKS/ISI09_trends.pdfAug 05, 2009  · Data Mining Trevor Hastie, Stanford University 7 Netflix Challenge Netflix users

Data Mining Trevor Hastie, Stanford University 29

Neural Networks

1Z

Single (Hidden) Layer Perceptron

X X X1 2 3

Z Z Z3 42

Input Layer

Hidden Layer

Output Layer1Y Y 2

• Like a complex regression or logis-

tic regression model — more flexi-

ble, but less interpretable — a “black

box”.

• Hidden units Z1, Z2, . . . , Zm (4 here):

Zj = σ(α0j + αTj X)

σ(Z) = eZ/(1 + eZ) is the logistic

sigmoid activation function.

• Output is a linear regression or logis-

tic regression model in the Zj .

• Complexity controlled by m, ridge

regularization, and early stopping of

the backpropogation algorithm for fit-

ting the neural network.

Page 30: Modern Trends in Data Mining - Stanford Universityhastie/TALKS/ISI09_trends.pdfAug 05, 2009  · Data Mining Trevor Hastie, Stanford University 7 Netflix Challenge Netflix users

Data Mining Trevor Hastie, Stanford University 30

Support Vector Machines

• •

••

••

••

•Margin

Margin

Decision Boundary

• Maximize the gap (margin) between

the two classes on the training data.

• If not separable

– enlarge the feature space via basis

expansions (e.g. polynomials).

– use a “soft” margin (allow limited

overlap).

• Solution depends on a small num-

ber of points (“support vectors”) —

3 here.

Decision boundary xT β + β0 = 0 is linear in the features (but could

be nonlinear in original variables).

Page 31: Modern Trends in Data Mining - Stanford Universityhastie/TALKS/ISI09_trends.pdfAug 05, 2009  · Data Mining Trevor Hastie, Stanford University 7 Netflix Challenge Netflix users

Data Mining Trevor Hastie, Stanford University 31

Properties of SVMs

• Primarily used for classification problems. Builds a linear

classifier f(X) = β0 + β1X1 + β2X2 + . . . βpXp.

If f(X) > 0, classify as +1, else if f(X) < 0, classify as -1.

• Generalizations use kernels (“radial basis functions”):

f(X) = α0 +

N∑

i=1

αiK(X, xi)

– K is a symmetric function, e.g. K(X, xi) = e−γ||X−xi||2

,

and each xi is one of the samples (vectors)

– Many of the αi = 0; the rest are “support points”.

• Extensions to regression, logistic regression, PCA, . . ..

• Well developed mathematics — function estimation in

Reproducing Kernel Hilbert Spaces.

Page 32: Modern Trends in Data Mining - Stanford Universityhastie/TALKS/ISI09_trends.pdfAug 05, 2009  · Data Mining Trevor Hastie, Stanford University 7 Netflix Challenge Netflix users

Data Mining Trevor Hastie, Stanford University 32

SVM via Loss + Penalty

-3 -2 -1 0 1 2 3

0.0

0.5

1.0

1.5

2.0

2.5

3.0

Binomial Log-likelihoodSupport Vector

yf(x) (margin)

Loss

With f(x) = xT β + β0 and

yi ∈ −1, 1, consider

minβ0, β

N∑

i=1

[1−yif(xi)]++λ

2‖β‖2

This hinge loss criterion

is equivalent to the SVM,

with λ monotone in B.

Compare with

minβ0, β

N∑

i=1

log[

1 + e−yif(xi)]

2‖β‖2

This is binomial deviance loss, and the solution is “ridged” linear

logistic regression.

Page 33: Modern Trends in Data Mining - Stanford Universityhastie/TALKS/ISI09_trends.pdfAug 05, 2009  · Data Mining Trevor Hastie, Stanford University 7 Netflix Challenge Netflix users

Data Mining Trevor Hastie, Stanford University 33

Classification and Regression Trees

Can handle huge datasets

Can handle mixed predictors—quantitative and qualitative

Easily ignore redundant variables

Handle missing data elegantly

Small trees are easy to interpret

large trees are hard to interpret

Often prediction performance is poor

Page 34: Modern Trends in Data Mining - Stanford Universityhastie/TALKS/ISI09_trends.pdfAug 05, 2009  · Data Mining Trevor Hastie, Stanford University 7 Netflix Challenge Netflix users

Data Mining Trevor Hastie, Stanford University 34

600/1536

280/1177

180/1065

80/861

80/652

77/423

20/238

19/236 1/2

57/185

48/113

37/101 1/12

9/72

3/229

0/209

100/204

36/123

16/94

14/89 3/5

9/29

16/81

9/112

6/109 0/3

48/359

26/337

19/110

18/109 0/1

7/227

0/22

spam

spam

spam

spam

spam

spam

spam

spam

spam

spam

spam

spam

email

email

email

email

email

email

email

email

email

email

email

email

email

email

email

email

email

email

email

email

email

ch$<0.0555

remove<0.06

ch!<0.191

george<0.005

hp<0.03

CAPMAX<10.5

receive<0.125 edu<0.045

our<1.2

CAPAVE<2.7505

free<0.065

business<0.145

george<0.15

hp<0.405

CAPAVE<2.907

1999<0.58

ch$>0.0555

remove>0.06

ch!>0.191

george>0.005

hp>0.03

CAPMAX>10.5

receive>0.125 edu>0.045

our>1.2

CAPAVE>2.7505

free>0.065

business>0.145

george>0.15

hp>0.405

CAPAVE>2.907

1999>0.58

Tree fit to theSPAM dataMisclassification error 8.7%

Page 35: Modern Trends in Data Mining - Stanford Universityhastie/TALKS/ISI09_trends.pdfAug 05, 2009  · Data Mining Trevor Hastie, Stanford University 7 Netflix Challenge Netflix users

Data Mining Trevor Hastie, Stanford University 35

Ensemble Methods and Boosting

Classification trees can be simple, but often produce noisy (bushy)

or weak (stunted) classifiers.

• Bagging (Breiman, 1996): Fit many large trees to

bootstrap-resampled versions of the training data, and classify

by majority vote.

• Random Forests (Breiman 1999): Improvements over bagging.

• Boosting (Freund & Shapire, 1996): Fit many smallish trees to

reweighted versions of the training data. Classify by weighted

majority vote.

In general Boosting ≻ Random Forests ≻ Bagging ≻ Single Tree.

Page 36: Modern Trends in Data Mining - Stanford Universityhastie/TALKS/ISI09_trends.pdfAug 05, 2009  · Data Mining Trevor Hastie, Stanford University 7 Netflix Challenge Netflix users

Data Mining Trevor Hastie, Stanford University 36

0 500 1000 1500 2000 2500

0.04

00.

045

0.05

00.

055

0.06

00.

065

0.07

0

Spam Data

Number of Trees

Tes

t Err

orBaggingRandom ForestGradient Boosting (5 Node)

Page 37: Modern Trends in Data Mining - Stanford Universityhastie/TALKS/ISI09_trends.pdfAug 05, 2009  · Data Mining Trevor Hastie, Stanford University 7 Netflix Challenge Netflix users

Data Mining Trevor Hastie, Stanford University 37

Training Sample

Weighted Sample

Weighted Sample

Weighted Sample

Training Sample

Weighted Sample

Weighted Sample

Weighted SampleWeighted Sample

Training Sample

Weighted Sample

Training Sample

Weighted Sample

Weighted SampleWeighted Sample

Weighted Sample

Weighted Sample

Weighted Sample

Training Sample

Weighted Sample

CM (x)

C3(x)

C2(x)

C1(x)

Boosting

• Average many trees, each

grown to re-weighted versions

of the training data.

• Weighting decorrelates the

trees, by focussing on regions

missed by past trees.

• Final Classifier is weighted av-

erage of classifiers:

C(x) = sign[

∑Mm=1 αmCm(x)

]

Page 38: Modern Trends in Data Mining - Stanford Universityhastie/TALKS/ISI09_trends.pdfAug 05, 2009  · Data Mining Trevor Hastie, Stanford University 7 Netflix Challenge Netflix users

Data Mining Trevor Hastie, Stanford University 38

Modern Gradient Boosting (Friedman, 2001)

• Fits an additive model

Fm(X) = T1(X) + T2(X) + T3(X) + . . . + Tm(X)

where each of the Tj(X) is a tree in X.

• Can be used for regression, logistic regression and more. For

example, gradient boosting for regression works by repeatedly

fitting trees to the residuals:

1. Fit a small tree T1(X) to Y .

2. Fit a small tree T2(X) to the residual Y − T1(X).

3. Fit a small tree T3(X) to the residual Y − T1(X) − T2(X).

and so on.

• m is the tuning parameter, which must be chosen using a

validation set (m too big will overfit).

Page 39: Modern Trends in Data Mining - Stanford Universityhastie/TALKS/ISI09_trends.pdfAug 05, 2009  · Data Mining Trevor Hastie, Stanford University 7 Netflix Challenge Netflix users

Data Mining Trevor Hastie, Stanford University 39

Gradient Boosting - Details

• For general loss function L[Y, Fm(X) + Tm+1(X)], fit a tree to

the gradient ∂L/∂Fm rather than residual.

• Shrink the new contribution before adding into the model:

Fm(X) + γTm+1(X). This slows the forward stagewise

algorithm, leading to improved performence.

• Tree depth determines interaction order of the model.

• Boosting will eventually overfit; number of terms m is a tuning

parameter.

• As γ ↓ 0, boosting path behaves like ℓ1 regularization path in

the space of trees.

Page 40: Modern Trends in Data Mining - Stanford Universityhastie/TALKS/ISI09_trends.pdfAug 05, 2009  · Data Mining Trevor Hastie, Stanford University 7 Netflix Challenge Netflix users

Data Mining Trevor Hastie, Stanford University 40

0 200 400 600 800 1000

0.24

0.26

0.28

0.30

0.32

0.34

0.36

Adaboost Stumps for Classification

Iterations

Tes

t Mis

clas

sific

atio

n E

rror

Adaboost StumpAdaboost Stump shrink 0.1

Page 41: Modern Trends in Data Mining - Stanford Universityhastie/TALKS/ISI09_trends.pdfAug 05, 2009  · Data Mining Trevor Hastie, Stanford University 7 Netflix Challenge Netflix users

Data Mining Trevor Hastie, Stanford University 41

0.0 0.2 0.4 0.6 0.8 1.0

0.0

0.2

0.4

0.6

0.8

1.0

Specificity

Sen

sitiv

ity

ROC curve for TREE, SVM and Boosting on SPAM data

ooo

Boosting − Error: 4.5%SVM − Error: 6.7%TREE − Error: 8.7%

Boosting on SPAM

Boosting dominates all other

methods on SPAM data —

4.5% test error.

Used 1000 trees (depth 6) with

default settings for gbm pack-

age in R.

ROC curve obtained by vary-

ing the threshold of the classi-

fier.

Sensitivity: proportion of true

spam identified

Specificity: proportion of true

email identified.

Page 42: Modern Trends in Data Mining - Stanford Universityhastie/TALKS/ISI09_trends.pdfAug 05, 2009  · Data Mining Trevor Hastie, Stanford University 7 Netflix Challenge Netflix users

Data Mining Trevor Hastie, Stanford University 42

Matrix Completion

0 10 20 30 40 50 60 70

0

10

20

30

40

50

60

70

80

90

100

Complete

Movies

Raters

Example: Netflix problem.

We partially observe a ma-

trix of movie ratings (rows)

by a number of raters

(columns). The goal is to

predict the future ratings of

these same individuals for

movies they have not yet

rated (or seen).0 10 20 30 40 50 60 70

0

10

20

30

40

50

60

70

80

90

100

Observed

Movies

Raters

We solve this problem by fitting an ℓ1 regularized SVD path to the

observed data matrix (Mazumder, Hastie and Tibshirani, 2009).

Page 43: Modern Trends in Data Mining - Stanford Universityhastie/TALKS/ISI09_trends.pdfAug 05, 2009  · Data Mining Trevor Hastie, Stanford University 7 Netflix Challenge Netflix users

Data Mining Trevor Hastie, Stanford University 43

ℓ1 regularized SVD

minX

||PΩ(X) − PΩ(X)||2F + λ||X||∗

• PΩ is projection onto observed values (sets unobserved to 0).

• ||X||∗ is nuclear norm — sum of singular values.

• This is a convex optimization problem (Candes 2008), with

solution given by a soft thresholded SVD — singular values are

shrunk toward zero, many set to zero.

• Our algorithm iteratively soft-thresholds the SVD of

PΩ(X) + P⊥Ω (X) =

PΩ(X) − PΩ(X)

+ X

= Sparse + Low-Rank

• Using Lanczos techniques and warm starts, we can efficiently

compute solution paths for very large matrices (50K ×50K)

Page 44: Modern Trends in Data Mining - Stanford Universityhastie/TALKS/ISI09_trends.pdfAug 05, 2009  · Data Mining Trevor Hastie, Stanford University 7 Netflix Challenge Netflix users

Data Mining Trevor Hastie, Stanford University 44

Software

• R is free software for statistical modeling, graphics and a

general programming environment. Works on PCs, Macs and

Linux/Unix platforms. All the models here can be fit in R. R

grew from its predecessor Splus, and both implement the S

language developed at Bell Labs in the 80s.

• SAS and their Enterprise Miner can fit some of the models

mentioned in this talk, with good data-handling capabilities,

and high-end user interfaces.

• Salford Systems has commercial versions of trees, random

forests and gradient boosting.

• SVM software is all over, but beware of patent infringements if

put to commercial use.

• Many free versions of neural network software; Google will find.