computational and statistical learning...
TRANSCRIPT
Computational and StatisticalLearning Theory
TTIC 31120
Prof. Nati Srebro
Lecture 17:Stochastic Optimization
Part II: Realizable vs Agnostic RatesPart III: Nearest Neighbor Classification
Stochastic (Sub)-Gradient Descent
If ๐ป๐ ๐ค, ๐ง 2 โค ๐บ then with appropriate step size:
๐ผ ๐น ๐ค๐ โค inf๐คโ๐ฒ, ๐ค 2โค๐ต
๐น ๐ค + ๐๐ต2๐บ2
๐
Similarly, also Stochastic Mirror Descent
Optimize ๐ญ ๐ = ๐ผ๐โผ๐ ๐ ๐, ๐ s.t. ๐ โ ๐ฆ1. Initialize ๐ค1 = 0 โ ๐ฒ2. At iteration ๐ก = 1,2,3, โฆ
1. Sample ๐ง๐ก โผ ๐ (Obtain ๐๐ก s.t. ๐ผ ๐๐ก โ ๐๐น(๐ค๐ก))
2. ๐ค๐ก+1 = ฮ ๐ฒ ๐ค๐ก โ ๐๐ก๐ป๐ ๐ค๐ก , ๐ง๐ก
3. Return ๐ค๐ =1
๐ฯ๐ก=1๐ ๐ค๐ก
Stochastic Gradient DescentOnline Gradient Descent[Cesa-Binachi et al 02]
online2stochastic
๐๐
[Zinkevich 03] [Nemirovski Yudin 78]
Online Mirror Descent Stochastic Mirror Descent[Shalev-Shwatz Singer 07] [Nemirovski Yudin 78]
Stochastic Optimization
min๐คโ๐ฒ
๐น(๐ค)
based only on stochastic information on ๐นโข Only unbiased estimates of ๐น ๐ค , ๐ป๐น(๐ค)
โข No direct access to ๐น
E.g., fixed ๐(๐ค, ๐ง) but ๐ unknownโข Optimize ๐น(๐ค) based on iid sample ๐ง1, ๐ง2, โฆ , ๐ง๐~๐
โข ๐ = ๐ป๐(๐ค, ๐ง๐ก) is unbiased estimate of ๐ป๐น ๐ค
โข Traditional applicationsโข Optimization under uncertainty
โข Uncertainty about network performance
โข Uncertainty about client demands
โข Uncertainty about system behavior in control problems
โข Complex systems where its easier to sample then integrate over ๐ง
= ๐ผ๐ง~๐[๐ ๐ค, ๐ง ]
Machine Learning isStochastic Optimization
minโ
๐ฟ โ = ๐ผ๐งโผ๐ โ โ, ๐ง = ๐ผ๐ฅ,๐ฆโผ๐ ๐๐๐ ๐ โ ๐ฅ , ๐ฆ
โข Optimization variable: predictor โ
โข Objective: generalization error ๐ฟ(โ)
โข Stochasticity over ๐ง = (๐ฅ, ๐ฆ)
โGeneral Learningโ โก Stochastic Optimization:
ValdimirVapnik
ArkadiNemirovskii
โขFocus on computational efficiency
โขGenerally assumes unlimited sampling- as in monte-carlo methods for complicated objectives
โขOptimization variable generally a vector in a normed space- complexity control through norm
โขMostly convex objectives
Stochastic Optimization
โขFocus on sample size
โขWhat can be done with a fixed number of samples?
โขAbstract hypothesis classes- linear predictors, but also combinatorial hypothesis classes- generic measures of complexity such as VC-dim, fat shattering, Radamacher
โข Also non-convex classes and loss functions
Statistical Learningvs
ValdimirVapnik
ArkadiNemirovskii
Two Approaches to Stochastic Optimization / Learning
min๐คโ๐ฒ
๐น(๐ค) = ๐ผ๐ง~๐[๐ ๐ค, ๐ง ]
โข Empirical Risk Minimization (ERM) / Sample Average Approximation (SAA):โข Collect sample z1,โฆ,zm
โข Minimize ๐น๐ ๐ค =1
๐ฯ๐ ๐ ๐ค, ๐ง๐
โข Analysis typically based on Uniform Convergence
โข Stochastic Approximation (SA): [Robins Monro 1951]
โข Update ๐ค๐ก based on ๐ง๐กโข E.g., based on ๐๐ก = ๐ป๐(๐ค, ๐ง๐ก)
โข E.g.: stochastic gradient descent
โข Online-to-batch conversion of online algorithmโฆ
SA/SGD for Machine Learning
โข In learning with ERM, need to optimize
เท๐ค = arg min๐คโ๐ฒ
๐ฟ๐(๐ค) ๐ฟ๐ ๐ค =1
๐ฯ๐ โ(๐ค, ๐ง๐)
โข ๐ฟ๐ ๐ค is expensive to evaluate exactlyโ ๐(๐๐) time
โข Cheap to get unbiased gradient estimateโ ๐(๐) time
๐ โผ ๐๐๐๐(1โฆ๐) ๐ = ๐ปโ ๐ค, ๐ง๐
๐ผ ๐ = ฯ๐1
๐๐ปโ ๐ค, ๐ง๐ = ๐ป๐ฟ๐(๐ค)
โข SGD guarantee:
๐ผ ๐ฟ๐ เดฅ๐ค ๐ โค inf๐คโ๐ฒ
๐ฟ๐ ๐ค +sup ๐ปโ 2
2 sup ๐ค 22
๐
SGD for SVM
min ๐ฟ๐ ๐ค ๐ . ๐ก. ๐ค 2 โค ๐ต
Use ๐๐ก = ๐ป๐ค๐๐๐ ๐ โ๐๐๐๐ ๐ค๐ก, ๐๐๐ก ๐ฅ ; ๐ฆ๐๐ก for random ๐๐ก
Initialize ๐ค 0 = 0At iteration t:โข Pick ๐ โ 1โฆ๐ at random
โข If ๐ฆ๐ ๐ค๐ก , ๐ ๐ฅ๐ < 1,
๐ค ๐ก+1 โ ๐ค ๐ก + ๐๐ก๐ฆ๐๐ ๐ฅ๐else: ๐ค ๐ก+1 โ ๐ค ๐ก
โข If ๐ค ๐ก+12> ๐ต, then ๐ค ๐ก+1 โ ๐ต
๐ค ๐ก+1
๐ค ๐ก+12
Return เดฅ๐ค ๐ =1
๐ฯ๐ก=1๐ ๐ค ๐ก
๐ ๐ฅ 2 โค ๐บ ๐๐ก 2 โค ๐บ ๐ฟ๐ เดฅ๐ค ๐ โค ๐ฟ๐ เท๐ค +๐ต2๐บ2
๐
(in expectation over randomness in algorithm)
Stochastic vs Batch
x1,y1
x2,y2
x3,y3
x4,y4
x5,y5
xm,ym
๐1 = โ๐๐๐ ๐ (๐ค, (๐ฅ1, ๐ฆ1) )
๐2 = โ๐๐๐ ๐ (๐ค, (๐ฅ2, ๐ฆ2) )
๐3 = โ๐๐๐ ๐ (๐ค, (๐ฅ3, ๐ฆ3) )
๐4 = โ๐๐๐ ๐ (๐ค, (๐ฅ4, ๐ฆ4) )
๐5 = โ๐๐๐ ๐ (๐ค, ๐ฅ5, ๐ฆ5 )
๐๐ = โ๐๐๐ ๐ (๐ค, (๐ฅ๐, ๐ฆ๐) )
๐1 = โ๐๐๐ ๐ (๐ค, (๐ฅ1, ๐ฆ1) )
๐2 = โ๐๐๐ ๐ (๐ค, (๐ฅ2, ๐ฆ2) )
๐3 = โ๐๐๐ ๐ (๐ค, (๐ฅ3, ๐ฆ3) )
๐4 = โ๐๐๐ ๐ (๐ค, (๐ฅ4, ๐ฆ4) )
๐5 = โ๐๐๐ ๐ (๐ค, (๐ฅ5, ๐ฆ5) )
๐๐ = โ๐๐๐ ๐ (๐ค, (๐ฅ๐, ๐ฆ๐) )
๐ค โ ๐ค โ ๐1
๐ค โ ๐ค โ ๐2
๐ค โ ๐ค โ ๐3
๐ค โ ๐ค โ ๐4
๐ค โ ๐ค โ ๐๐โ1
๐ค โ ๐ค โ ๐๐๐ค โ ๐ค โ ๐๐
๐ค โ ๐ค โ ๐5
min ๐ฟ๐ ๐ค ๐ . ๐ก. ๐ค 2 โค ๐ต
โ๐ฟ๐ ๐ค =1
๐ฯ๐๐
Stochastic vs Batchโข Intuitive argument: if only taking simple gradient steps, better
to be stochastic
โข To get ๐ฟ๐ ๐ค โค ๐ฟ๐ เท๐ค + ๐๐๐๐ก:
#iter cost/iter runtime
Batch GD ๐ต2๐บ2/๐๐๐๐ก2 ๐๐ ๐๐
๐ต2๐บ2
๐๐๐๐ก2
SGD ๐ต2๐บ2/๐๐๐๐ก2 ๐ ๐
๐ต2๐บ2
๐๐๐๐ก2
โข Comparison to methods with a log 1/๐๐๐๐ก dependence that use the structure of ๐ฟ๐(๐ค) (not only local access)?
โข How small should ๐๐๐๐ก be?
โข What about ๐ฟ ๐ค , which is what we really care about?
Overall Analysis of ๐ฟ๐(๐ค)โข Recall for ERM: ๐ฟ๐ เท๐ค โค ๐ฟ๐ ๐คโ + 2sup
๐ค๐ฟ๐ ๐ค + ๐ฟ๐ ๐ค
โข For ๐๐๐๐ก suboptimal ERM เดฅ๐ค:
๐ฟ๐ เดฅ๐ค โค ๐ฟ๐ ๐คโ + 2sup๐ค
๐ฟ๐ ๐ค โ ๐ฟ๐ ๐ค + ๐ฟ๐ เดฅ๐ค โ ๐ฟ๐ เท๐ค
โข Take ๐๐๐๐ก โ ๐๐๐ ๐ก, i.e. #๐๐ก๐๐ ๐ โ ๐ ๐๐๐๐๐ ๐ ๐๐ง๐ ๐
โข To ensure ๐ฟ๐ ๐ค โค ๐ฟ๐ ๐คโ + ๐:
๐,๐ = ๐๐ต2๐บ2
๐2
เท๐ค = arg min๐ค โค๐ต
๐ฟ๐(๐ค) ๐คโ = arg min๐ค โค๐ต
๐ฟ๐(๐ค)
๐๐๐๐๐๐ฅ
๐๐๐ ๐ก โค 2๐ต2๐บ2
๐๐๐๐๐ก โค
๐ต2๐บ2
๐
Direct Online-to-Batch:SGD on ๐ฟ๐(๐ค)
min๐ค
๐ฟ๐(๐ค)
use ๐๐ก = ๐ป๐คโ๐๐๐๐ ๐ฆ ๐ค, ๐ ๐ฅ for random ๐ฆ, ๐ฅ~๐
๐ผ ๐๐ก = ๐ป๐ฟ๐ ๐ค
Initialize ๐ค 0 = 0At iteration t:โข Draw ๐ฅ๐ก , ๐ฆ๐ก~๐
โข If ๐ฆ๐ก ๐ค๐ก , ๐ ๐ฅ๐ก < 1,
๐ค ๐ก+1 โ ๐ค ๐ก + ๐๐ก๐ฆ๐ก๐ ๐ฅ๐กelse: ๐ค ๐ก+1 โ ๐ค ๐ก
Return เดฅ๐ค ๐ =1
๐ฯ๐ก=1๐ ๐ค ๐ก
๐ฟ๐ เดฅ๐ค ๐ โค inf๐ค 2โค๐ต
๐ฟ๐ ๐ค +๐ต2๐บ2
๐
๐ = ๐ = ๐๐ต2๐บ2
๐2
SGD for Machine Learning
Initialize ๐ค 0 = 0At iteration t:โข Draw ๐ฅ๐ก , ๐ฆ๐ก~๐
โข If ๐ฆ๐ก ๐ค๐ก , ๐ ๐ฅ๐ก < 1,
๐ค ๐ก+1 โ ๐ค ๐ก + ๐๐ก๐ฆ๐ก๐ ๐ฅ๐กelse: ๐ค ๐ก+1 โ ๐ค ๐ก
Return เดฅ๐ค ๐ =1
๐ฯ๐ก=1๐ ๐ค ๐ก
Draw ๐ฅ1, ๐ฆ1 , โฆ , ๐ฅ๐, ๐ฆ๐ ~๐
Initialize ๐ค 0 = 0At iteration t:โข Pick ๐ โ 1โฆ๐ at random
โข If ๐ฆ๐ ๐ค๐ก , ๐ ๐ฅ๐ < 1,
๐ค ๐ก+1 โ ๐ค ๐ก + ๐๐ก๐ฆ๐๐ ๐ฅ๐else: ๐ค ๐ก+1 โ ๐ค ๐ก
โข ๐ค ๐ก+1 โ ๐๐๐๐ ๐ค ๐ก+1 ๐ก๐ ๐ค โค ๐ต
Return เดฅ๐ค ๐ =1
๐ฯ๐ก=1๐ ๐ค ๐ก
Direct SA (online2batch) Approach:SGD on ERM:min๐ค 2โค๐ต
๐ฟ๐ ๐ค
min๐ค
๐ฟ ๐ค
โข Fresh sample at each iteration, ๐ = ๐โข No need to project nor require ๐ค โค ๐ตโข Implicit regularization via early stopping
โข Can have ๐ > ๐ iterationsโข Need to project to ๐ค โค ๐ตโข Explicit regularization via โ๐คโ
SGD for Machine Learning
Initialize ๐ค 0 = 0At iteration t:โข Draw ๐ฅ๐ก , ๐ฆ๐ก~๐
โข If ๐ฆ๐ก ๐ค๐ก , ๐ ๐ฅ๐ก < 1,
๐ค ๐ก+1 โ ๐ค ๐ก + ๐๐ก๐ฆ๐ก๐ ๐ฅ๐กelse: ๐ค ๐ก+1 โ ๐ค ๐ก
Return เดฅ๐ค ๐ =1
๐ฯ๐ก=1๐ ๐ค ๐ก
Draw ๐ฅ1, ๐ฆ1 , โฆ , ๐ฅ๐, ๐ฆ๐ ~๐
Initialize ๐ค 0 = 0At iteration t:โข Pick ๐ โ 1โฆ๐ at random
โข If ๐ฆ๐ ๐ค๐ก , ๐ ๐ฅ๐ < 1,
๐ค ๐ก+1 โ ๐ค ๐ก + ๐๐ก๐ฆ๐๐ ๐ฅ๐else: ๐ค ๐ก+1 โ ๐ค ๐ก
โข ๐ค ๐ก+1 โ ๐๐๐๐ ๐ค ๐ก+1 ๐ก๐ ๐ค โค ๐ต
Return เดฅ๐ค ๐ =1
๐ฯ๐ก=1๐ ๐ค ๐ก
Direct SA (online2batch) Approach:SGD on ERM:min๐ค 2โค๐ต
๐ฟ๐ ๐ค
min๐ค
๐ฟ ๐ค
๐ฟ เดฅ๐ค ๐ โค ๐ฟ ๐คโ +๐ต2๐บ2
๐๐ฟ เดฅ๐ค ๐ โค ๐ฟ ๐คโ + 2
๐ต2๐บ2
๐+
๐ต2๐บ2
๐
๐คโ = arg min๐ค โค๐ต
๐ฟ(๐ค)
๐๐ก = ๐ต2/๐บ2๐ก
SGD for Machine Learning
Initialize ๐ค 0 = 0At iteration t:โข Draw ๐ฅ๐ก , ๐ฆ๐ก~๐
โข If ๐ฆ๐ก ๐ค๐ก , ๐ ๐ฅ๐ก < 1,
๐ค ๐ก+1 โ ๐ค ๐ก + ๐๐ก๐ฆ๐ก๐ ๐ฅ๐กelse: ๐ค ๐ก+1 โ ๐ค ๐ก
Return เดฅ๐ค ๐ =1
๐ฯ๐ก=1๐ ๐ค ๐ก
Draw ๐ฅ1, ๐ฆ1 , โฆ , ๐ฅ๐, ๐ฆ๐ ~๐
Initialize ๐ค 0 = 0At iteration t:โข Pick ๐ โ 1โฆ๐ at random
โข If ๐ฆ๐ ๐ค๐ก , ๐ ๐ฅ๐ < 1,
๐ค ๐ก+1 โ ๐ค ๐ก + ๐๐ก๐ฆ๐๐ ๐ฅ๐else: ๐ค ๐ก+1 โ ๐ค ๐ก
โข ๐ค ๐ก+1 โ ๐ค ๐ก+1 โ ๐๐ค(๐ก)
Return เดฅ๐ค ๐ =1
๐ฯ๐ก=1๐ ๐ค ๐ก
Direct SA (online2batch) Approach:
SGD on RERM:
min๐ฟ๐ ๐ค +๐
2โ๐คโ
min๐ค
๐ฟ ๐ค
โข Fresh sample at each iteration, ๐ = ๐โข No need shrink ๐คโข Implicit regularization via early stopping
โข Can have ๐ > ๐ iterationsโข Need to shrink ๐คโข Explicit regularization via โ๐คโ
SGD vs ERM
๐ค 0
เดฅ๐ค ๐
เท๐ค๐คโ
๐๐ต2๐บ2
๐
argmin๐ค
๐ฟ๐(๐ค)
(overfit)
๐ป > ๐w/ proj
๐คโ = arg min๐ค โค๐ต
๐ฟ(๐ค)เท๐ค = arg min๐ค โค๐ต
๐ฟ๐(๐ค)
Mixed Approach: SGD on ERM
0 1,000,000 2,000,000 3,000,000
0.052
0.054
0.056
0.058
# iterations k
Test
mis
clas
sifi
cati
on
err
or
m=300,000m=400,000m=500,000
Reuters RCV1 data, CCAT task
โข The mixed approach (reusing examples) can make sense
Mixed Approach: SGD on ERM
0 1,000,000 2,000,000 3,000,000
0.052
0.054
0.056
0.058
# iterations k
Test
mis
clas
sifi
cati
on
err
or
m=300,000m=400,000m=500,000
Reuters RCV1 data, CCAT task
โข The mixed approach (reusing examples) can make senseโข Still: fresh samples are better
)With a larger training set, can reduce generalization error faster) Larger training set means less runtime to get target generalization error
Online Optimization vs Stochastic Approximation
โข In both Online Setting and Stochastic Approximation โข Receive samples sequentiallyโข Update w after each sample
โข But, in Online Setting:โข Objective is empirical regret, i.e. behavior on observed instancesโข ๐ง๐ก chosen adversarialy (no distribution involved)
โข As opposed on Stochastic Approximation:โข Objective is ๐ผ โ ๐ค, ๐ง , i.e. behavior on โfutureโ samplesโข i.i.d. samples ๐ง๐ก
โข Stochastic Approximation is a computational approach,Online Learning is an analysis setupโข E.g. โFollow the leaderโ
Part II:Realizable vs Agnostic
Rates
Realizable vs Agnostic Rates
โข Recall for finite hypothesis classes:
๐ฟ๐ โ โค infโโโ
๐ฟ๐(โ) + 2log |โ|+log เต2 ๐ฟ
2๐ ๐ = ๐
log โ
๐๐
โข But in the realizable case, if infโโโ
๐ฟ๐(โ) = 0:
๐ฟ๐ โ โคlog โ +log
1
๐ฟ
๐ ๐ = ๐
log โ
๐
โข Also for VC-classes, in general ๐ = ๐๐๐ถ๐๐๐
๐๐while in the
realizable case ๐ = ๐๐๐ถ๐๐๐โ log 1/๐
๐
โข What happens if ๐ฟโ = infโโโ
๐ฟ๐(โ) is low, but not zero?
Estimating the Bias of a Coin
๐ โ ฦธ๐ โคlog เต2 ๐ฟ2๐
๐ โ ฦธ๐ โค2 ๐ log เต2 ๐ฟ
๐+2 log เต2 ๐ฟ3๐
Optimistic VC bound(aka ๐ฟโ-bound, multiplicative bound)
โ = argminโโโ
๐ฟ๐(โ) ๐ฟโ = infโโโ
๐ฟ(โ)
โข For a hypothesis class with VC-dim ๐ท, w.p. 1-๐ฟ over n samples:
๐ฟ โ โค ๐ฟโ + 2 ๐ฟโ๐ท log ฮค2๐๐
๐ท+log เต2 ๐ฟ
๐+ 4
๐ท log ฮค2๐๐๐ท+log เต2 ๐ฟ
๐
= inf๐ผ
1 + ๐ผ ๐ฟโ + 1 +1
๐ผ4๐ท log ฮค2๐๐
๐ท+log เต2 ๐ฟ
๐
โข Sample complexity to get ๐ฟ โ โค ๐ฟโ + ๐:
๐ ๐ = ๐๐ท
๐โ ๐ฟโ + ๐
๐log
1
๐
โข Extends to bounded real-valued loss in terms of VC-subgraph dim
From Parametric to Scale Sensitive๐ฟ โ = ๐ผ ๐๐๐ ๐ โ ๐ฅ , ๐ฆ โ โ โ
โข Instead of VC-dim or VC-subgraph-dim (โ #params), rely on metric scale to control complexity, e.g.:
โ = ๐ค โฆ ๐ค, ๐ฅ ๐ค 2 โค ๐ต }
โข Learning depends on:
โข Metric complexity measures: fat shattering dimension, covering numbers, Rademacher Complexity
โข Scale sensitivity of loss (bound on derivatives or โmarginโ)
โข For โwith Rademacher Complexity โ๐, and ๐๐๐ ๐ โฒ โค ๐บ:
๐ฟ โ โค ๐ฟโ + 2๐บโ๐ +log เต2 ๐ฟ2๐
โค ๐ฟโ + ๐๐บ2๐ + log เต2 ๐ฟ
2๐
โ๐ โค๐
๐
๐ =
โ๐ โ =๐ต2 sup ๐ฅ 2
๐
Non-Parametric Optimistic Rate for Smooth Loss
โข Theorem: for any โ with (worst case) RademacherComplexity โ๐(โ), and any smooth loss with ๐๐๐ ๐ โฒโฒ โค ๐ป, ๐๐๐ ๐ โค ๐, w.p. 1 โ ๐ฟ over n samples:
โข Sample complexity
Parametric vs Non-Parametric
Parametricdim(โ) โค ๐, ๐ โค ๐
Scale-Sensitive
โ๐ โ โค เต๐น ๐
Lipschitz: ๐โฒ โค ๐บ(e.g. hinge, โ1) ๐บ ๐ท
๐ + ๐ฟโ๐บ๐ท๐
๐บ2๐ ๐
Smooth: ๐โฒโฒ โค ๐ป(e.g. logistic, Huber, smoothed hinge)
๐ป ๐ท๐ + ๐ฟโ
๐ป๐ท๐
๐ป ๐ ๐ + ๐ฟโ
๐ป๐ ๐
Smooth & strongly convex: ๐ โค ๐โฒโฒ โค ๐ป(e.g. square loss)
๐ป
๐โ ๐ป ๐ท
๐๐ป ๐ ๐ + ๐ฟโ
๐ป๐ ๐
Min-max tight up to poly-log factors
Optimistic Learning Guarantees
๐ฟ โ โค 1 + ๐ผ ๐ฟโ + 1 +1
๐ผเทจ๐
๐
๐
๐ ๐ โค เทจ๐๐
๐โ ๐ฟโ + ๐
๐
Parametric classes
Scale-sensitive classes with smooth loss
Perceptron gurantee
Margin Bounds
Stability-based guarantees with smooth loss
Online Learning/Optimization with smooth loss
ร Non-param (scale sensitive) classes with non-smooth loss
ร Online Learning/Optimization with non-smooth loss
Why Optimistic Guarantees?
๐ฟ โ โค 1 + ๐ผ ๐ฟโ + 1 +1
๐ผเทจ๐
๐
๐
๐ ๐ โค เทจ๐๐
๐โ ๐ฟโ + ๐
๐
โข Optimistic regime typically relevant regime:
โข Approximation error ๐ฟโ โ Estimation error ๐
โข If ๐ โช ๐ฟโ, better to spend energy on lowering approx. error(use more complex class)
โข Often important in highlighting true phenomena
Part III:Nearest Neighbor
Classification
The Nearest Neighbor Classifierโข Training sample S = ๐ฅ1, ๐ฆ1 , โฆ , ๐ฅ๐, ๐ฆ๐
โข Want to predict label of new point ๐ฅ
โข The Nearest Neighbor Rule:
โข Find the closest training point: ๐ = argmin๐๐(๐ฅ, ๐ฅ๐)
โข Predict label of ๐ฅ as ๐ฆ๐
?
The Nearest Neighbor Classifierโข Training sample S = ๐ฅ1, ๐ฆ1 , โฆ , ๐ฅ๐, ๐ฆ๐
โข Want to predict label of new point ๐ฅ
โข The Nearest Neighbor Rule:
โข Find the closest training point: ๐ = argmin๐๐(๐ฅ, ๐ฅ๐)
โข Predict label of ๐ฅ as ๐ฆ๐
โข As learning rule: ๐๐ ๐ = โ where โ(๐ฅ) = ๐ฆarg min๐
๐ ๐ฅ,๐ฅ๐
เทฉ๐ ๐ โ เทฉ๐(๐โฒ)๐
เทฉ๐ ๐ = (๐๐ ๐ , ๐ ๐ )๐ โ ๐โฒ ๐๐ โ ๐โฒ ๐
Where is the Bias Hiding?
โข What is the right โdistanceโ between images? Between sound waves? Between sentences?
โข Option 1: ๐ ๐ฅ, ๐ฅโฒ = ๐ ๐ฅ โ ๐ ๐ฅโฒ 2
โข What representation ๐(๐ฅ)?
โข Find the closest training point: ๐ = argmin๐๐(๐ฅ, ๐ฅ๐)
โข Predict label of ๐ฅ as ๐ฆ๐
เทฉ๐ ๐ โ เทฉ๐(๐โฒ)๐
เทฉ๐ ๐ = (๐๐ ๐ , ๐ ๐ )๐ โ ๐โฒ ๐ ๐ โ ๐โฒ โ
Where is the Bias Hiding?
โข What is the right โdistanceโ between images? Between sound waves? Between sentences?
โข Option 1: ๐ ๐ฅ, ๐ฅโฒ = ๐ ๐ฅ โ ๐ ๐ฅโฒ 2
โข What representation ๐(๐ฅ)?
โข Maybe a different distance? ๐ ๐ฅ โ ๐ ๐ฅโฒ 1? ๐ ๐ฅ โ ๐ ๐ฅ โ? sin(โ (๐ ๐ฅ , ๐ ๐ฅโฒ )? ๐พ๐ฟ(๐(๐ฅ)||๐ ๐ฅโฒ )?
โข Find the closest training point: ๐ = argmin๐๐(๐ฅ, ๐ฅ๐)
โข Predict label of ๐ฅ as ๐ฆ๐
Where is the Bias Hiding?
โข What is the right โdistanceโ between images? Between sound waves? Between sentences?
โข Option 1: ๐ ๐ฅ, ๐ฅโฒ = ๐ ๐ฅ โ ๐ ๐ฅโฒ 2
โข What representation ๐(๐ฅ)?
โข Maybe a different distance? ๐ ๐ฅ โ ๐ ๐ฅโฒ 1? ๐ ๐ฅ โ ๐ ๐ฅ โ? sin(โ (๐ ๐ฅ , ๐ ๐ฅโฒ )? ๐พ๐ฟ(๐(๐ฅ)||๐ ๐ฅโฒ )?
โข Option 2: Special-purpose distance measure on ๐ฅโข E.g. edit distance, deformation measure, etc
โข Find the closest training point: ๐ = argmin๐๐(๐ฅ, ๐ฅ๐)
โข Predict label of ๐ฅ as ๐ฆ๐
Nearest Neighbor Learning Guarantee
โข Optimal predictor: โโ = argmin ๐ฟ๐(โ)
โโ ๐ฅ = แ+1, ๐ ๐ฅ > 0.5
โ1, ๐ ๐ฅ < 0.5๐ ๐ฅ = ๐๐(๐ฆ = 1|๐ฅ)
โข For the NN rule with ๐ ๐ฅ, ๐ฅโฒ = ๐ ๐ฅ โ ๐ ๐ฅโฒ 2, and ๐:๐ณ โ [0,1] ๐:
๐ผ๐โผ๐๐ ๐ฟ ๐๐ ๐ โค 2๐ฟ โโ + 4๐๐๐
๐+1 ๐
๐ ๐ฅ โ ๐ ๐ฅโฒ โค ๐๐ โ ๐(๐ฅ, ๐ฅโฒ)
Data Fit / Complexity Tradeoff
โข k-Nearest Neighbor: predict according to majority among ๐ closest point from S.
๐ผ๐โผ๐๐ ๐ฟ ๐๐ ๐ โค 2๐ฟ(โโ) + 4๐๐๐
๐+1 ๐
k-Nearest Neighbor:Data Fit / Complexity Tradeoff
k=1 k=5 k=12
k=50 k=100 k=200
S= h*=
k-Nearest Neighbor Guarantee
โข For k-NN with ๐ ๐ฅ, ๐ฅโฒ = ๐ ๐ฅ โ ๐ ๐ฅโฒ 2, and ๐:๐ณ โ [0,1]๐:
๐ผ๐โผ๐๐ ๐ฟ ๐๐๐ ๐ โค 1 + 8๐ ๐ฟ โโ +
6๐๐ ๐ + ๐๐+1 ๐
โข Should increase ๐ with sample size ๐
โข Above theory suggests ๐๐ โ ๐ฟ โโ 2/3 โ ๐2
3(๐+1)
โข โUniversalโ Learning: for any โsmoothโ ๐ and representation ๐ โ (with continuous ๐(๐ฆ|๐ ๐ฅ )), if we increase k slowly enough, we will eventually converge to optimal ๐ฟ(โโ)
โข Very non-uniform: sample complexity depends not only on โโ, but also on ๐
๐ ๐ฅ โ ๐ ๐ฅโฒ โค ๐๐ โ ๐(๐ฅ, ๐ฅโฒ)
Uniform and Non-Uniform Learnability
โข Definition: A hypothesis class โ is agnostically PAC-Learnable if there exists a
learning rule ๐ด such that โ๐, ๐ฟ > 0, โ๐ ๐, ๐ฟ , โ๐, โ๐, โ๐โผ๐๐ ๐,๐ฟ๐ฟ ,
๐ฟ๐ ๐ด ๐ โค ๐ฟ๐ โ + ๐
โข Definition: A hypothesis class โ is non-uniformly learnable if there exists a
learning rule ๐ด such that โ๐, ๐ฟ > 0, โโ, โ๐ ๐, ๐ฟ, ๐ , โ๐, โ๐โผ๐๐ ๐,๐ฟ,๐๐ฟ ,
๐ฟ๐ ๐ด ๐ โค ๐ฟ๐ โ + ๐
โข Definition: A hypothesis class โ is โconsistently learnableโ if there exists a
learning rule ๐ด such that โ๐, ๐ฟ > 0, โโ โ๐, โ๐ ๐, ๐ฟ, โ, ๐ , โ๐โผ๐๐ ๐,๐ฟ,โ,๐๐ฟ ,
๐ฟ๐ ๐ด ๐ โค ๐ฟ๐ โ + ๐
Realizable/Optimistic Guarantees: ๐ dependence through ๐ฟ๐(โ)