0% found this document useful (0 votes)
10 views38 pages

Lecture3 2015

Uploaded by

hu jack
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views38 pages

Lecture3 2015

Uploaded by

hu jack
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 38

STA

 414/2104:    
Machine  Learning    

Russ  Salakhutdinov  
Department of Computer Science!
Department of Statistics!
[email protected]!
h0p://www.cs.toronto.edu/~rsalakhu/  

Lecture 3  
Parametric  Distribu>ons      
•  We  want  model  the  probability  distribu>on                                  of  a  random  
variable  x  given  a  finite  set  of  observa>ons:    

Need  to  determine          given    

•  We  will  also  assume  that  the  data  points  are  i.i.d    

•  We  will  focus  on  the  maximum  likelihood  es>ma>on      


•  Remember  curve  fiFng  example.  
Linear  Basis  Func>on  Models  
•  Remember,  the  simplest  linear  model  for  regression:    

where                                                                        is  a  d-­‐dimensional  input  vector  (covariates).    

Key  property:  linear  func>on  of  the  parameters                                                      .    


•  However,  it  is  also  a  linear  func>on  of  input  variables.    
   Instead  consider:  

where                        are  known  as  basis  func>ons.  

•  Typically                                    ,      so  that  w0  acts  as  a  bias  (or  intercept).  


•  In  the  simplest  case,  we  use  linear  bases  func>ons:  
•  Using  nonlinear  basis  allows  the  func>ons                                to  be  nonlinear  func>ons  of  
the  input  space.    
Linear  Basis  Func>on  Models  
Polynomial  basis  func>ons:     Gaussian  basis  func>ons:  

Basis  func>ons  are  global:  small   Basis  func>ons  are  local:  small  changes  in  x  
changes  in  x  affect  all  basis  func>ons.   only  affect  nearby  basis  func>ons.  
µj  and  s  control  loca>on  and  scale  (width).  
Linear  Basis  Func>on  Models  
Sigmoidal  basis  func>ons  

Basis  func>ons  are  local:  small  changes  


in  x  only  affect  nearby  basis  func>ons.  
µj  and  s  control  loca>on  and  scale  
(slope).  

•  Decision  boundaries  will  be  linear  in  the  feature  space            but  would  
correspond  to  nonlinear  boundaries  in  the  original  input  space  x.      
•  Classes  that  are  linearly  separable  in  the  feature  space                    need  not  
be  linearly  separable  in  the  original  input  space.    
Linear  Basis  Func>on  Models  
Original input space Corresponding feature space using
two Gaussian basis functions

• We define two Gaussian basis functions with centers shown by the green crosses,
and with contours shown by the green circles.

• Linear decision boundary (right) is obtained by using logistic regression, and


corresponds to the nonlinear decision boundary in the input space (left, black curve).
Maximum  Likelihood  
•  As  before,  assume  observa>ons  arise  from  a  determinis>c  func>on  with  an  
addi>ve  Gaussian  noise:  

which  we  can  write  as:    

•  Given  observed  inputs                                                                                  ,  and  corresponding  target  


values                                                                  ,      under  i.i.d  assump>on,  we  can  write  down  the  
likelihood  func>on:  

where                      
Maximum  Likelihood  
Taking  the  logarithm,  we  obtain:  

sum-­‐of-­‐squares  error  func>on  

Differen>a>ng  and  seFng  to  zero  yields:      


Maximum  Likelihood  
Differen>a>ng  and  seFng  to  zero  yields:      

Solving  for  w,  we  get:  


The  Moore-­‐
Penrose  pseudo-­‐
inverse,              .  

where          is  known  as  the  design  matrix:  


Geometry  of  Least  Squares  
•  Consider  an  N-­‐dimensional  space,  so  
that                                                                          is  a  vector  in  
that  space.  
•  Each  basis  func>on                                evaluated  
at  the  N  data  points,  can  be  represented  
as  a  vector  in  the  same  space.              
•  If  M  is  less  than  N,  then  the  M  basis  
func>on                                  will  span  a  linear  
subspace  S  of  dimensionality  M.  

•  Define:  
•  The  sum-­‐of-­‐squares  error  is  equal  to  
the  squared  Euclidean  distance  
between  y  and  t  (up  to  a  factor  of  1/2).    

The  solu>on  corresponds  to  the  orthogonal  projec>on  of  t  onto  the  subspace  S.    
Sequen>al  Learning  
•  The  training  data  examples  are  presented  one  at  a  >me,  and  the  model  
parameter  are  updated  a_er  each  such  presenta>on  (online  learning):  

weights  a_er   learning   vector  of  deriva>ves  of    the  squared  


seeing  training   rate   error  w.r.t.  the  weights  on  the  
case    t+1   training  case  presented  at  >me  t.  

•  For  the  case  of  sum-­‐of-­‐squares  error  func>on,  we  obtain:  

•  Stochas>c  gradient  descent:  if  the  training  examples  are  picked  at  random  
(dominant  technique  when  learning  with  very  large  datasets).    
•  Care  must  be  taken  when  choosing  learning  rate  to  ensure  convergence.      
Regularized  Least  Squares  
•  Let  us  consider  the  following  error  func>on:    
¸  is  called  the  
regulariza>on  
coefficient.  
Data  term  +  Regulariza>on  term  

•  Using  sum-­‐of-­‐squares  error  func>on  with  a  quadra>c  penaliza>on  


term,  we  obtain:    

Ridge  
which  is  minimized  by  seFng:     regression  

The  solu>on  adds  a  posi>ve  constant  to  the  diagonal  of                            This  makes  the  
problem  nonsingular,  even  if                          is  not  of  full  rank  (e.g.  when  the  number  
of  training  examples  is  less  than  the  number  of  basis  func>ons).      
Effect  of  Regulariza>on  
•  The  overall  error  func>on  is  the  sum  
of  two  parabolic  bowls.    

•  The  combined  minimum  lies  on  the  


line  between  the  minimum  of  the  
squared  error  and  the  origin.  

•  The  regularizer  shrinks  model  


parameters  to  zero.    
Other  Regularizers  
Using  a  more  general  regularizer,  we  get:  

Lasso   Quadra>c  
The  Lasso    
•  Penalize  the  absolute  value  of  the  weights:  

•  For  sufficiently  large  ¸,  some  of  the  coefficients  will  be  driven  to  
exactly  zero,  leading  to  a  sparse  model.    
•  The  above  formula>on  is  equivalent  to:  

unregularized  sum-­‐of-­‐squares  error  

•  The  two  approaches  are  related  using  Lagrange  mul>plies.    


•  The  Lasso  solu>on  is  a  quadra>c  programming  problem:  can  be  
solved  efficiently.    
Lasso  vs.  Quadra>c  Penalty  
Lasso  tends  to  generate  sparser  solu>ons  compared  to  a  quadra>c  
regualrizer  (some>mes  called  L1  and  L2  regularizers).  
Sta>s>cal  Decision  Theory  
•  We  now  develop  a  small  amount  of  theory  that  provides  a  framework  
for  developing  many  of  the  models  we  consider.    
•  Suppose  we  have  a  real-­‐valued  input  vector  x  and  a  corresponding  
target  (output)  value  t  with  joint  probability  distribu>on:    

•  Our  goal  is  predict  target  t  given  a  new  value  for  x:  
- for  regression:  t  is  a  real-­‐valued  con>nuous  target.  
- for  classifica>on:  t  a  categorical  variable  represen>ng  class  labels.      

The  joint  probability  distribu>on                            provides  a  complete  summary  of  


uncertain>es  associated  with  these  random  variables.    
Determining                            from  training  data  is  known  as  the  inference  problem.      
Example:  Classifica>on  
Medical  diagnosis:  Based  on  the  X-­‐ray  image,  we  would  like  determine  
whether  the  pa>ent  has  cancer  or  not.      
•  The  input  vector  x  is  the  set  of  pixel  intensi>es,  and  the  output  variable  t  will  
represent  the  presence  of  cancer,  class  C1,  or  absence  of  cancer,  class  C2.    

 C1:  Cancer  present  

C2:  Cancer  absent  

x  -­‐-­‐  set  of  pixel  intensi>es  


•  Choose  t  to  be  binary:  t=0  correspond  to  class  C1,  and  t=1  corresponds  to  C2.  

Inference  Problem:  Determine  the  joint  distribu>on                ,              or  equivalently                          


                       .    However,  in  the  end,  we  must  make  a  decision  of  whether  to  give  
treatment  to  the  pa>ent  or  not.    
Example:  Classifica>on  
Informally:  Given  a  new  X-­‐ray  image,  our  goal  is  to  decide  which  of  the  two  
classes  that  image  should  be  assigned  to.    

•  We  could  compute  condi>onal  probabili>es  of  the  two  classes,  given  the  input  
image:    

posterior  probability  of   probability  of  observed   prior  probability  


Ck  given  observed  data.   data  given  Ck   for  class  Ck  

Bayes’  Rule  

•  If  our  goal  to  minimize  the  probability  of  assigning  x  to  the  wrong  class,  then  
we  should  choose  the  class  having  the  highest  posterior  probability.    
Minimizing  Misclassifica>on  Rate  
Goal:  Make  as  few  misclassifica>ons  as  
possible.  We  need  a  rule  that  assigns  each  
value  of  x  to  one  of  the  available  classes.    

Divide  the  input  space  into  regions  


(decision  regions),  such  that  all  points  in    
           are  assigned  to  class            .    

red+green  regions:  input   blue  region:  input  belongs  


belongs  to  class  C2,  but  is   to  class  C1,  but  is  assigned  
assigned  to  C1     to  C2  
Minimizing  Misclassifica>on  Rate  
Minimizing  Misclassifica>on  Rate  
Minimizing  Misclassifica>on  Rate  

Using                                                                                            :  To  minimize  the  probability  of  making  mistake,  we  


assign  each  x  to  the  class  for  which  the  posterior  probability                                  is  largest.      
Expected  Loss  
•  Loss  Func>on:  overall  measure  of  loss  incurred  by  taking  any  of  the  available  
decisions.    
•  Suppose  that  for  x,  the  true  class  is  Ck,  but  we  assign  x  to  class  j    
     !  incur  loss  of  Lkj    (k,j  element  of  a  loss  matrix).        

Consider  medical  diagnosis  example:  example  of  a  loss  matrix:  

Decision  
Truth  

Expected  Loss:  

Goal  is  to  choose  regions                as  to  minimize  expected  loss.  
Reject  Op>on  
Regression  
Let  x  2  Rd  denote  a  real-­‐valued  input  vector,  and  t  2  R  denote  a  real-­‐
valued  random  target  (output)  variable  with  joint  the  distribu>on                            

•  The  decision  step  consists  of  finding  an  es>mate  y(x)  of  t  for  each  input  x.        
•  Similar  to  classifica>on  case,  to  quan>fy  what  it  means  to  do  well  or  
poorly  on  a  task,  we  need  to  define  a  loss  (error)  func>on:  

•  The  average,  or  expected,  loss  is  given  by:  

•  If  we  use  squared  loss,  we  obtain:  


Squared  Loss  Func>on  
•  If  we  use  squared  loss,  we  obtain:  

•  Our  goal  is  to  choose  y(x)  so  as  to  minimize  the  expected  squared  loss.    
•  The  op>mal  solu>on  (if  we  assume  a  completely  flexible  func>on)  is  the  
condi>onal  average:  

The  regression  func>on  y(x)  that  


minimizes  the  expected  squared  loss  is  
given  by  the  mean  of  the  condi>onal  
distribu>on  
Squared  Loss  Func>on  
•  If  we  use  squared  loss,  we  obtain:  

•  Plugging    into  expected  loss:  

expected  loss  is  minimized     intrinsic  variability  of  the    


when     target  values.  

Because  it  is  independent  noise,  it  


represents  an  irreducible  minimum  
value  of  expected  loss.  
Other  Loss  Func>on  
•  Simple  generaliza>on  of  the  squared  loss,  called  the  Minkowski  loss:  

•  The  minimum  of                    is  given  by:  


- the  condi>onal  mean  for  q=2,    
- the  condi>onal  median  when  q=1,  and    
- the  condi>onal  mode  for  q  !  0.    
Bias-­‐Variance  Decomposi>on  
•  Introducing  a  regulariza>on  term  can  help  us  control  overfiFng.  But  how  
can  we  determine  a  suitable  value  of  the  regulariza>on  coefficient?    

•  Let  us  examine  the  expected  squared  loss  func>on.  Remember:  

for  which  the  op>mal  predic>on  is  given    


by  the  condi>onal  expecta>on:   intrinsic  variability  of  the  target  
values:  The  minimum  achievable  
value  of  expected  loss  

•  If  we  model                    using  a  parametric  func>on                                    then  from  a  


Bayesian  perspec>ve,  the  uncertainly  in  our  model  is  expressed  
through  the  posterior  distribu>on  over  parameters  w.    
•  We  first  look  at  the  frequen>st  perspec>ve.    
Bias-­‐Variance  Decomposi>on  
•  From  a  frequen>st  perspec>ve:  we  make  a  point  es>mate  of  w*  based  
on  the  dataset  D.  
•  We  next  interpret  the  uncertainly  of  this  es>mate  through  the  
following  thought  experiment:  
-­‐ Suppose  we  had  a  large  number  of  datasets,  each  of  size  N,  
where  each  dataset  is  drawn  independently  from    
-­‐ For  each  dataset  D,  we  can  obtain  a  predic>on  func>on  
-­‐ Different  datasets  will  give  different  predic>on  func>ons.  
-­‐ The  performance  of  a  par>cular  learning  algorithm  is  then  assessed  
by  taking  the  average  over  the  ensemble  of  these  datasets.    

•  Let  us  consider  the  expression:  

•  Note  that  this  quan>ty  depends  on  a  par>cular  dataset  D.    


Bias-­‐Variance  Decomposi>on  
•  Consider:  

•  Adding  and  subtrac>ng  the  term                                                      we  obtain    

•  Taking  the  expecta>on  over              the  last  term  vanishes,  so  we  get:  
Bias-­‐Variance  Trade-­‐off  

Average  predic>ons  over  all   Solu>ons  for  individual  datasets   Intrinsic  variability  
datasets  differ  from  the   vary  around  their  averages  -­‐-­‐  how   of  the  target  
op>mal  regression  func>on.   sensi>ve  is  the  func>on  to  the   values.  
par>cular  choice  of  the  dataset.    

•  Trade-­‐off  between  bias  and  variance:  With  very  flexible  models  (high  
complexity)  we  have  low  bias  and  high  variance;  With  rela>vely  rigid  models  
(low  complexity)  we  have  high  bias  and  low  variance.      
•  The  model  with  the  op>mal  predic>ve  capabili>es  has  to  balance  between  bias  
and  variance.    
Bias-­‐Variance  Trade-­‐off  
•  Consider  the  sinusoidal  dataset.  We  generate  100  datasets,  each  containing  
N=25  points,  drawn  independently  from  
High  variance   Low  variance  

Low  bias   High  bias  


Bias-­‐Variance  Trade-­‐off  
•  Consider  the  sinusoidal  dataset.  We  generate  100  datasets,  each  containing  
N=25  points,  drawn  independently  from  
High  variance  
•  Note  that  averaging  many  solu>ons  to  the  
complex  model  with  M=25  data  points  represents  a  
very  good  fit  to  the  regression  func>on    

•  Averaging  may  be  a  beneficial  procedure.    

•  Let  us  examine  the  bias-­‐variance  trade-­‐off  


quan>ta>vely.    

Low  bias  
Bias-­‐Variance  Trade-­‐off  
•  Consider  the  sinusoidal  dataset.  We  generate  100  datasets,  each  containing  
N=25  points,  drawn  independently  from  

•  The  average  predic>on  is  es>mated  as:    

•  And  the  integrated  squared  bias  and  variance  are  given  by:    

where  the  integral  over  x  weighted  by  the  distribu>on  p(x)  is  approximated  
by  the  finite  sum  over  data  points  drawn  from  that  distribu>on.    
Bias-­‐Variance  Trade-­‐off  

From  these  plots  note  that  over-­‐regularized  model  (large  ¸)  has  high  bias,  and  
under-­‐regularized  model  (low  ¸)  has  high  variance.    
Bea>ng  the  Bias-­‐Variance  Trade-­‐off  
•  We  can  reduce  the  variance  by  averaging  over  many  models  trained  on  
different  datasets:    
-  In  prac>ce,  we  only  have  a  single  observed  dataset.  If  we  had  many  
independent  training  sets,  we  would  be  be0er  off  combining  them  into  
one  large  training  dataset.  With  more  data,  we  have  less  variance.    
•  Given  a  standard  training  set  D  of  size  N,  we  could  generate  new  training  
sets,  N,  by  sampling  examples  from  D  uniformly  and  with  replacement.      
-  This  is  called  bagging  and  it  works  quite  well  in  prac>ce.    

•  Given  enough  computa>on,  we  would  be  be0er  off  resor>ng  to  the  
Bayesian  framework  (which  we  will  discuss  next):  
-  Combine  the  predic>ons  of  many  models  using  the  posterior  
probability  of  each  parameter  vector  as  the  combina>on  weight.      

You might also like