SlideShare a Scribd company logo
1 of 63
Download to read offline
Machine	
  Learning	
  Specializa0on	
  
Multiple Regression:
Linear regression with multiple features
Emily Fox & Carlos Guestrin
Machine Learning Specialization
University of Washington
1 ©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
Machine	
  Learning	
  Specializa0on	
  2	
   ©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
Training
Data
Feature
extraction
ML
model
Quality
metric
ML algorithm
y
x ŷ
ŵ
Machine	
  Learning	
  Specializa0on	
  3	
   ©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
square feet (sq.ft.)
price($)
x
y
Simple linear regression model
yi = w0+w1 xi + εi
f(x) = w0+w1 x
Machine	
  Learning	
  Specializa0on	
  
More complex functions
of a single input
©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
Machine	
  Learning	
  Specializa0on	
  
Polynomial regression
©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
Machine	
  Learning	
  Specializa0on	
  6	
  
Fit data with a line or … ?
©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
square feet (sq.ft.)
price($)
x
y
You show
your friend
your analysis
Machine	
  Learning	
  Specializa0on	
  7	
  
Fit data with a line or … ?
©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
square feet (sq.ft.)
price($)
x
y
Dude, it’s
not a linear
relationship!
Machine	
  Learning	
  Specializa0on	
  8	
  
What about a quadratic function?
©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
square feet (sq.ft.)
price($)
x
y
Dude, it’s
not a linear
relationship!
Machine	
  Learning	
  Specializa0on	
  9	
   ©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
square feet (sq.ft.)
price($)
x
y
f(x) = w0 + w1 x+ w2 x2
What about a quadratic function?
Machine	
  Learning	
  Specializa0on	
  10	
  
Even higher order polynomial
©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
square feet (sq.ft.)
price($)
x
y
f(x) = w0 + w1 x+ w2 x2 + … + wp xp
Machine	
  Learning	
  Specializa0on	
  11	
  
Polynomial regression
Model:
yi = w0 + w1 xi+ w2 xi
2 + … + wp xi
p + εi
feature 1 = 1 (constant)
feature 2 = x
feature 3 = x2
…
feature p+1 = xp
©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
treat as different features
parameter 1 = w0
parameter 2 = w1
parameter 3 = w2
…
parameter p+1 = wp
Machine	
  Learning	
  Specializa0on	
  
Other functions of one input
©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
Machine	
  Learning	
  Specializa0on	
  13	
  
11.512.012.513.013.514.0
Month
log(Price)
1997−01 1999−01 2001−01 2003−01 2005−01 2007−01 2009−01 2011−01 2013−01
Motivating application:
Detrending time series
©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
House sales recorded monthly
yi = $ of ith house sale
ti = month of ith house sale
Machine	
  Learning	
  Specializa0on	
  14	
  
11.512.012.513.013.514.0
Month
log(Price)
1997−01 1999−01 2001−01 2003−01 2005−01 2007−01 2009−01 2011−01 2013−01
Trends over time
©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
On average, house prices
tend to increase with time
Machine	
  Learning	
  Specializa0on	
  15	
  
11.512.012.513.013.514.0
Month
log(Price)
1997−01 1999−01 2001−01 2003−01 2005−01 2007−01 2009−01 2011−01 2013−01
Seasonality
©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
Most	
  houses	
  listed	
  in	
  summer	
  
+	
  	
  
Good	
  houses	
  sell	
  quickly
Few	
  homes	
  listed	
  in	
  Nov./Dec.	
  
+	
  	
  
Transac0ons	
  oSen	
  leSover	
  inventory	
  
or	
  special	
  circumstances
Machine	
  Learning	
  Specializa0on	
  16	
  
An example detrending
Model:
yi = w0 + w1 ti + w2 sin(2πti / 12 - Φ) + εi
©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
Linear trend Seasonal component =
Sinusoid with period 12
(resets annually)
Unknown phase/shift
Trigonometric identity: sin(a-b)=sin(a)cos(b)-cos(a)sin(b)
à sin(2πti / 12 - Φ) = sin(2πti / 12)cos(Φ) - cos(2πti / 12)sin(Φ)
Machine	
  Learning	
  Specializa0on	
  17	
  
An example detrending
Equivalently,
yi = w0 + w1 ti + w2 sin(2πti / 12)
+ w3 cos(2πti / 12) + εi
feature 1 = 1 (constant)
feature 2 = t
feature 3 = sin(2πt/12)
feature 4 = cos(2πt/12)
©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
Machine	
  Learning	
  Specializa0on	
  18	
  
11.512.012.513.013.514.0
Month
log(Price)
1997−01 1999−01 2001−01 2003−01 2005−01 2007−01 2009−01 2011−01 2013−01
Detrended housing data
Fit polynomial trend and
sinusoidal seasonal component
©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
5th order polynomial
+
sin/cos basis
Machine	
  Learning	
  Specializa0on	
  19	
  
Zoom in…
Fit polynomial trend and
sinusoidal seasonal component
©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
5th order polynomial
+
sin/cos basis
Machine	
  Learning	
  Specializa0on	
  20	
  
Other examples of seasonality
©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
Weather modeling
(e.g., temperature, rainfall)
Demand forecasting
(e.g., jacket purchases)
Motion capture data
Flu monitoring
Machine	
  Learning	
  Specializa0on	
  
More generally…
©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
Machine	
  Learning	
  Specializa0on	
  22	
  
Generic basis expansion
Model:
yi = w0h0(xi) + w1 h1(xi) + … + wD hD(xi)+ εi
= wj hj(xi) + εi
feature 1 = h0(x)…often 1
feature 2 = h1(x)… e.g., x
feature 3 = h2(x)… e.g., x2 or sin(2πx/12)
…
feature p+1 = hp(x)… e.g., xp
©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
jth regression coefficient
or weight
jth feature
DX
j=0
Machine	
  Learning	
  Specializa0on	
  23	
  
Generic basis expansion
Model:
yi = w0h0(xi) + w1 h1(xi) + … + wD hD(xi)+ εi
= wj hj(xi) + εi
feature 1 = h0(x)…often 1 (constant)
feature 2 = h1(x)… e.g., x
feature 3 = h2(x)… e.g., x2 or sin(2πx/12)
…
feature D+1 = hD(x)… e.g., xp
©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
DX
j=0
Machine	
  Learning	
  Specializa0on	
  24	
   ©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
Training
Data
Feature
extraction
ML
model
Quality
metric
ML algorithm
y
x ŷ
ŵ
x h(x)
Machine	
  Learning	
  Specializa0on	
  
Incorporating multiple inputs
©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
Machine	
  Learning	
  Specializa0on	
  26	
  
Predictions just based on
house size
©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
square feet (sq.ft.)
price($)
x
y
Only 1 bathroom!
Not same as my
3 bathrooms
Machine	
  Learning	
  Specializa0on	
  27	
  
Add more inputs
©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
square feet (sq.ft.)
price($)
x[1]
y
x[2]
f(x) = w0 + w1 sq.ft.
+ w2 #bath
Machine	
  Learning	
  Specializa0on	
  28	
  
Many possible inputs
- Square feet
- # bathrooms
- # bedrooms
- Lot size
- Year built
- …
©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
Machine	
  Learning	
  Specializa0on	
  29	
  
Reading your mind
©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
very sad very happy
Features are
brain region
intensities
Machine	
  Learning	
  Specializa0on	
  30	
  
General notation
Output: y
Inputs: x = (x[1],x[2],…, x[d])
Notational conventions:
x[j] = jth input (scalar)
hj(x) = jth feature (scalar)
xi = input of ith data point (vector)
xi[j] = jth input of ith data point (scalar)
©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
d-dim vector
scalar
Machine	
  Learning	
  Specializa0on	
  31	
  
Simple hyperplane
©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
Model:
yi = w0 + w1 xi[1] + … + wd xi[d] + εi
feature 1 = 1
feature 2 = x[1] … e.g., sq. ft.
feature 3 = x[2] … e.g., #bath
…
feature d+1 = x[d] … e.g., lot size
Machine	
  Learning	
  Specializa0on	
  32	
  
More generically…
D-dimensional curve
©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
Model:
yi = w0 h0(xi) + w1 h1(xi) + … + wD hD(xi) + εi
= wj hj(xi) + εi
feature 1 = h0(x) … e.g., 1
feature 2 = h1(x) … e.g., x[1] = sq. ft.
feature 3 = h2(x) … e.g., x[2] = #bath
or, log(x[7]) x[2] = log(#bed) x #bath
…
feature D+1 = hD(x) … some other function of x[1],…, x[d]
DX
j=0
Machine	
  Learning	
  Specializa0on	
  33	
  
More on notation
# observations (xi,yi) : N
# inputs x[j] : d
# features hj(x) : D
©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
Machine	
  Learning	
  Specializa0on	
  
Interpreting the fitted function
©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
Machine	
  Learning	
  Specializa0on	
  35	
   ©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
square feet (sq.ft.)
price($)
x
y
Interpreting the coefficients –
Simple linear regression
ŷ = ŵ0 + ŵ1 x
1 sq. ft.
predicted
change in $
Machine	
  Learning	
  Specializa0on	
  36	
  
fix
©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
Interpreting the coefficients –
Two linear features
square feet
(sq.ft.)
price($)
x[1]
y
x[2]
ŷ = ŵ0 + ŵ1 x[1] + ŵ2 x[2]
Machine	
  Learning	
  Specializa0on	
  37	
  
fix
©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
Interpreting the coefficients –
Two linear features
ŷ = ŵ0 + ŵ1 x[1] + ŵ2 x[2]
# bathrooms
price($)
x[2]
1 bathroom
predicted
change in $
y
For fixed
# sq.ft.!
Machine	
  Learning	
  Specializa0on	
  38	
  
fix fix fixfix
©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
Interpreting the coefficients –
Multiple linear features
ŷ = ŵ0 + ŵ1 x[1] + …+ŵj x[j] + … + ŵd x[d]
square feet
(sq.ft.)
price($)
x[1]
y
x[2]
Machine	
  Learning	
  Specializa0on	
  39	
   ©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
Interpreting the coefficients-
Polynomial regression
ŷ = ŵ0 + ŵ1x +… + ŵj xj + … + ŵp xp
square feet
(sq.ft.)
price($)
x
y
Can’t hold
other features
fixed!
Machine	
  Learning	
  Specializa0on	
  
Fitting D-dimensional curves
©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
Machine	
  Learning	
  Specializa0on	
  41	
   ©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
Training
Data
Feature
extraction
ML
model
Quality
metric
ML algorithm
ŵy
ŷh(x)
Machine	
  Learning	
  Specializa0on	
  
Step 1:
Rewrite the regression model
©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
Machine	
  Learning	
  Specializa0on	
  43	
  
Rewrite in matrix notation
For observation i
©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
yi = wj hj(xi) + εi
= + εiyi
DX
j=0
= + εi
Machine	
  Learning	
  Specializa0on	
  44	
  
Rewrite in matrix notation
For all observations together
©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
= +
Machine	
  Learning	
  Specializa0on	
  
Step 2:
Compute the cost
©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
Machine	
  Learning	
  Specializa0on	
  46	
   ©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
Training
Data
Feature
extraction
ML
model
Quality
metric
ML algorithm
y
h(x) ŷ
ŵ
Machine	
  Learning	
  Specializa0on	
  47	
  
“Cost” of using a given line
©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
square feet (sq.ft.)
price($)
x
y Residual sum of squares (RSS)
RSS(w0,w1) = (yi-[w0+w1xi])2
Machine	
  Learning	
  Specializa0on	
  48	
  
RSS for multiple regression
©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
square feet (sq.ft.)
price($)
y
RSS(w) = (yi- )2
x[1]
x[2]
ŷi =
Machine	
  Learning	
  Specializa0on	
  49	
  
RSS in matrix notation
©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
RSS(w) = (yi- h(xi)Tw)2
=
Why? (part 1)
Machine	
  Learning	
  Specializa0on	
  50	
  
RSS in matrix notation
©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
RSS(w) = (yi- h(xi)Tw)2
= (y-Hw)T(y-Hw)
residual1
residual2
residual3
…
residualN
residual1 residual2 residual3 … residualN
=
Why? (part 2)
Machine	
  Learning	
  Specializa0on	
  
Step 3:
Take the gradient
©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
Machine	
  Learning	
  Specializa0on	
  52	
  
Gradient of RSS
©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
RSS(w) = [(y-Hw)T(y-Hw)]
= -2HT(y-Hw)
Δ Δ
Why? By analogy to 1D case:
Machine	
  Learning	
  Specializa0on	
  
Step 4, Approach 1:
Set the gradient = 0
©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
Machine	
  Learning	
  Specializa0on	
  54	
  
Closed-form solution
©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
RSS(w) = -2HT(y-Hw) = 0
Δ
Solve for w:
Machine	
  Learning	
  Specializa0on	
  55	
  
Closed-form solution
©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
ŵ = ( HTH )-1 HTy
Invertible if:
Complexity of inverse:
Machine	
  Learning	
  Specializa0on	
  
Step 4, Approach 2:
Gradient descent
©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
Machine	
  Learning	
  Specializa0on	
  57	
  
Gradient descent
©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
while not converged
w(t+1) ß w(t) - η RSS(w(t))
Δ
-2HT(y-Hw)
Machine	
  Learning	
  Specializa0on	
  58	
  
Feature-by-feature update
©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
RSS(w) = (yi- h(xi)Tw)2
Partial with respect to wj
wj
(t+1) ß wj
(t) - η( )
Update to jth feature weight:
Machine	
  Learning	
  Specializa0on	
  59	
  
Interpreting elementwise
©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
wj
(t+1) ß wj
(t) + 2η hj(xi)(yi-ŷi(w(t)))
Update to jth feature weight:
square feet
(sq.ft.)
price($)
y
x[1]
x[2]
Machine	
  Learning	
  Specializa0on	
  60	
  
Summary of gradient descent
for multiple regression
©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
init w(1)=0 (or randomly, or smartly), t=1
while || RSS(w(t))|| > ε
for j=0,…,D
partial[j] =-2 hj(xi)(yi-ŷi(w(t)))
wj
(t+1) ß wj
(t) – η partial[j]
t ß t + 1
Δ
Machine	
  Learning	
  Specializa0on	
  62	
  
An extremely useful algorithm
©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
Machine	
  Learning	
  Specializa0on	
  
Summary for
multiple linear regression
©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  
Machine	
  Learning	
  Specializa0on	
  64	
  
What you can do now…
•  Describe polynomial regression
•  Detrend a time series using trend and seasonal components
•  Write a regression model using multiple inputs or features
thereof
•  Cast both polynomial regression and regression with multiple
inputs as regression with multiple features
•  Calculate a goodness-of-fit metric (e.g., RSS)
•  Estimate model parameters of a general multiple regression
model to minimize RSS:
-  In closed form
-  Using an iterative gradient descent algorithm
•  Interpret the coefficients of a non-featurized multiple
regression fit
•  Exploit the estimated model to form predictions
•  Explain applications of multiple regression beyond house
price modeling
©2015	
  Emily	
  Fox	
  &	
  Carlos	
  Guestrin	
  

More Related Content

What's hot

Reciprocal Allocation Method
Reciprocal Allocation MethodReciprocal Allocation Method
Reciprocal Allocation MethodPaulino Silva
 
Day 4 evaluating with add and subtract
Day 4 evaluating with add and subtractDay 4 evaluating with add and subtract
Day 4 evaluating with add and subtractErik Tjersland
 
7th PreAlg - L74--May4
7th PreAlg - L74--May47th PreAlg - L74--May4
7th PreAlg - L74--May4jdurst65
 
Extract information from pie
Extract information from pieExtract information from pie
Extract information from pieNadeem Uddin
 
Applications of calculus in commerce and economics
Applications of calculus in commerce and economicsApplications of calculus in commerce and economics
Applications of calculus in commerce and economicssumanmathews
 
Applications of calculus in commerce and economics ii
Applications of calculus in commerce and economics ii Applications of calculus in commerce and economics ii
Applications of calculus in commerce and economics ii sumanmathews
 
Alg II 3-4 Linear Programming
Alg II 3-4 Linear ProgrammingAlg II 3-4 Linear Programming
Alg II 3-4 Linear Programmingjtentinger
 

What's hot (11)

Funções 1
Funções 1Funções 1
Funções 1
 
Reciprocal Allocation Method
Reciprocal Allocation MethodReciprocal Allocation Method
Reciprocal Allocation Method
 
Day 4 evaluating with add and subtract
Day 4 evaluating with add and subtractDay 4 evaluating with add and subtract
Day 4 evaluating with add and subtract
 
Gm
GmGm
Gm
 
Algebra
AlgebraAlgebra
Algebra
 
7th PreAlg - L74--May4
7th PreAlg - L74--May47th PreAlg - L74--May4
7th PreAlg - L74--May4
 
Extract information from pie
Extract information from pieExtract information from pie
Extract information from pie
 
Applications of calculus in commerce and economics
Applications of calculus in commerce and economicsApplications of calculus in commerce and economics
Applications of calculus in commerce and economics
 
Applications of calculus in commerce and economics ii
Applications of calculus in commerce and economics ii Applications of calculus in commerce and economics ii
Applications of calculus in commerce and economics ii
 
TALLER N°2
TALLER N°2TALLER N°2
TALLER N°2
 
Alg II 3-4 Linear Programming
Alg II 3-4 Linear ProgrammingAlg II 3-4 Linear Programming
Alg II 3-4 Linear Programming
 

Viewers also liked

Dataiku - hadoop ecosystem - @Epitech Paris - janvier 2014
Dataiku  - hadoop ecosystem - @Epitech Paris - janvier 2014Dataiku  - hadoop ecosystem - @Epitech Paris - janvier 2014
Dataiku - hadoop ecosystem - @Epitech Paris - janvier 2014Dataiku
 
Music and Machine Learning
Music and Machine LearningMusic and Machine Learning
Music and Machine Learningbutest
 
Matrix Computations in Machine Learning
Matrix Computations in Machine LearningMatrix Computations in Machine Learning
Matrix Computations in Machine Learningbutest
 
Text-Independent Speaker Verification Report
Text-Independent Speaker Verification ReportText-Independent Speaker Verification Report
Text-Independent Speaker Verification ReportCody Ray
 
Text-Independent Speaker Verification
Text-Independent Speaker VerificationText-Independent Speaker Verification
Text-Independent Speaker VerificationCody Ray
 
SINH LÝ THỊ GIÁC
SINH LÝ THỊ GIÁCSINH LÝ THỊ GIÁC
SINH LÝ THỊ GIÁCSoM
 
Easter Seals Goodwill Industries Annual Report PDF in Adobe Reader[1]
Easter Seals Goodwill Industries Annual Report PDF in Adobe Reader[1]Easter Seals Goodwill Industries Annual Report PDF in Adobe Reader[1]
Easter Seals Goodwill Industries Annual Report PDF in Adobe Reader[1]Zoe Stetson
 
LẬU CẦU
LẬU CẦULẬU CẦU
LẬU CẦUSoM
 
Semi-supervised information extraction in semantical vector space - Jelena Mi...
Semi-supervised information extraction in semantical vector space - Jelena Mi...Semi-supervised information extraction in semantical vector space - Jelena Mi...
Semi-supervised information extraction in semantical vector space - Jelena Mi...Institute of Contemporary Sciences
 
Juhani%20 pallasamma%20the%20gometry%20of%20feeling%20..
Juhani%20 pallasamma%20the%20gometry%20of%20feeling%20..Juhani%20 pallasamma%20the%20gometry%20of%20feeling%20..
Juhani%20 pallasamma%20the%20gometry%20of%20feeling%20..kimberlywjs
 
Aula Cesga o cómo hacer de un curso presencial, un curso de blended learning
Aula Cesga o cómo hacer de un curso presencial, un curso de blended learningAula Cesga o cómo hacer de un curso presencial, un curso de blended learning
Aula Cesga o cómo hacer de un curso presencial, un curso de blended learningEncuentro Práctico ELE
 

Viewers also liked (15)

Dataiku - hadoop ecosystem - @Epitech Paris - janvier 2014
Dataiku  - hadoop ecosystem - @Epitech Paris - janvier 2014Dataiku  - hadoop ecosystem - @Epitech Paris - janvier 2014
Dataiku - hadoop ecosystem - @Epitech Paris - janvier 2014
 
Music and Machine Learning
Music and Machine LearningMusic and Machine Learning
Music and Machine Learning
 
Matrix Computations in Machine Learning
Matrix Computations in Machine LearningMatrix Computations in Machine Learning
Matrix Computations in Machine Learning
 
Text-Independent Speaker Verification Report
Text-Independent Speaker Verification ReportText-Independent Speaker Verification Report
Text-Independent Speaker Verification Report
 
Text-Independent Speaker Verification
Text-Independent Speaker VerificationText-Independent Speaker Verification
Text-Independent Speaker Verification
 
K-means and GMM
K-means and GMMK-means and GMM
K-means and GMM
 
Tic
TicTic
Tic
 
SINH LÝ THỊ GIÁC
SINH LÝ THỊ GIÁCSINH LÝ THỊ GIÁC
SINH LÝ THỊ GIÁC
 
Easter Seals Goodwill Industries Annual Report PDF in Adobe Reader[1]
Easter Seals Goodwill Industries Annual Report PDF in Adobe Reader[1]Easter Seals Goodwill Industries Annual Report PDF in Adobe Reader[1]
Easter Seals Goodwill Industries Annual Report PDF in Adobe Reader[1]
 
LẬU CẦU
LẬU CẦULẬU CẦU
LẬU CẦU
 
Semi-supervised information extraction in semantical vector space - Jelena Mi...
Semi-supervised information extraction in semantical vector space - Jelena Mi...Semi-supervised information extraction in semantical vector space - Jelena Mi...
Semi-supervised information extraction in semantical vector space - Jelena Mi...
 
Juhani%20 pallasamma%20the%20gometry%20of%20feeling%20..
Juhani%20 pallasamma%20the%20gometry%20of%20feeling%20..Juhani%20 pallasamma%20the%20gometry%20of%20feeling%20..
Juhani%20 pallasamma%20the%20gometry%20of%20feeling%20..
 
Control de JTable
Control de JTableControl de JTable
Control de JTable
 
FYP_AlexParker
FYP_AlexParkerFYP_AlexParker
FYP_AlexParker
 
Aula Cesga o cómo hacer de un curso presencial, un curso de blended learning
Aula Cesga o cómo hacer de un curso presencial, un curso de blended learningAula Cesga o cómo hacer de un curso presencial, un curso de blended learning
Aula Cesga o cómo hacer de un curso presencial, un curso de blended learning
 

Similar to C2.2

Similar to C2.2 (9)

C3.2.1
C3.2.1C3.2.1
C3.2.1
 
C3.7.1
C3.7.1C3.7.1
C3.7.1
 
C4.1.2
C4.1.2C4.1.2
C4.1.2
 
C3.5.1
C3.5.1C3.5.1
C3.5.1
 
Break even point(BEP)
Break even point(BEP)Break even point(BEP)
Break even point(BEP)
 
Hprec5.2
Hprec5.2Hprec5.2
Hprec5.2
 
mankiw10e _ lecture _ slides _ ch03.pptx
mankiw10e _ lecture _ slides _ ch03.pptxmankiw10e _ lecture _ slides _ ch03.pptx
mankiw10e _ lecture _ slides _ ch03.pptx
 
Optimization
OptimizationOptimization
Optimization
 
Gen Math Lesson 1.pptx
Gen Math Lesson 1.pptxGen Math Lesson 1.pptx
Gen Math Lesson 1.pptx
 

More from Daniel LIAO (13)

C4.5
C4.5C4.5
C4.5
 
C4.4
C4.4C4.4
C4.4
 
C4.3.1
C4.3.1C4.3.1
C4.3.1
 
Lime
LimeLime
Lime
 
C4.1.1
C4.1.1C4.1.1
C4.1.1
 
C3.6.1
C3.6.1C3.6.1
C3.6.1
 
C3.4.2
C3.4.2C3.4.2
C3.4.2
 
C3.4.1
C3.4.1C3.4.1
C3.4.1
 
C3.3.1
C3.3.1C3.3.1
C3.3.1
 
C3.1.2
C3.1.2C3.1.2
C3.1.2
 
C3.2.2
C3.2.2C3.2.2
C3.2.2
 
C3.1.logistic intro
C3.1.logistic introC3.1.logistic intro
C3.1.logistic intro
 
C3.1 intro
C3.1 introC3.1 intro
C3.1 intro
 

Recently uploaded

How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...RKavithamani
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 

Recently uploaded (20)

How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 

C2.2

  • 1. Machine  Learning  Specializa0on   Multiple Regression: Linear regression with multiple features Emily Fox & Carlos Guestrin Machine Learning Specialization University of Washington 1 ©2015  Emily  Fox  &  Carlos  Guestrin  
  • 2. Machine  Learning  Specializa0on  2   ©2015  Emily  Fox  &  Carlos  Guestrin   Training Data Feature extraction ML model Quality metric ML algorithm y x ŷ ŵ
  • 3. Machine  Learning  Specializa0on  3   ©2015  Emily  Fox  &  Carlos  Guestrin   square feet (sq.ft.) price($) x y Simple linear regression model yi = w0+w1 xi + εi f(x) = w0+w1 x
  • 4. Machine  Learning  Specializa0on   More complex functions of a single input ©2015  Emily  Fox  &  Carlos  Guestrin  
  • 5. Machine  Learning  Specializa0on   Polynomial regression ©2015  Emily  Fox  &  Carlos  Guestrin  
  • 6. Machine  Learning  Specializa0on  6   Fit data with a line or … ? ©2015  Emily  Fox  &  Carlos  Guestrin   square feet (sq.ft.) price($) x y You show your friend your analysis
  • 7. Machine  Learning  Specializa0on  7   Fit data with a line or … ? ©2015  Emily  Fox  &  Carlos  Guestrin   square feet (sq.ft.) price($) x y Dude, it’s not a linear relationship!
  • 8. Machine  Learning  Specializa0on  8   What about a quadratic function? ©2015  Emily  Fox  &  Carlos  Guestrin   square feet (sq.ft.) price($) x y Dude, it’s not a linear relationship!
  • 9. Machine  Learning  Specializa0on  9   ©2015  Emily  Fox  &  Carlos  Guestrin   square feet (sq.ft.) price($) x y f(x) = w0 + w1 x+ w2 x2 What about a quadratic function?
  • 10. Machine  Learning  Specializa0on  10   Even higher order polynomial ©2015  Emily  Fox  &  Carlos  Guestrin   square feet (sq.ft.) price($) x y f(x) = w0 + w1 x+ w2 x2 + … + wp xp
  • 11. Machine  Learning  Specializa0on  11   Polynomial regression Model: yi = w0 + w1 xi+ w2 xi 2 + … + wp xi p + εi feature 1 = 1 (constant) feature 2 = x feature 3 = x2 … feature p+1 = xp ©2015  Emily  Fox  &  Carlos  Guestrin   treat as different features parameter 1 = w0 parameter 2 = w1 parameter 3 = w2 … parameter p+1 = wp
  • 12. Machine  Learning  Specializa0on   Other functions of one input ©2015  Emily  Fox  &  Carlos  Guestrin  
  • 13. Machine  Learning  Specializa0on  13   11.512.012.513.013.514.0 Month log(Price) 1997−01 1999−01 2001−01 2003−01 2005−01 2007−01 2009−01 2011−01 2013−01 Motivating application: Detrending time series ©2015  Emily  Fox  &  Carlos  Guestrin   House sales recorded monthly yi = $ of ith house sale ti = month of ith house sale
  • 14. Machine  Learning  Specializa0on  14   11.512.012.513.013.514.0 Month log(Price) 1997−01 1999−01 2001−01 2003−01 2005−01 2007−01 2009−01 2011−01 2013−01 Trends over time ©2015  Emily  Fox  &  Carlos  Guestrin   On average, house prices tend to increase with time
  • 15. Machine  Learning  Specializa0on  15   11.512.012.513.013.514.0 Month log(Price) 1997−01 1999−01 2001−01 2003−01 2005−01 2007−01 2009−01 2011−01 2013−01 Seasonality ©2015  Emily  Fox  &  Carlos  Guestrin   Most  houses  listed  in  summer   +     Good  houses  sell  quickly Few  homes  listed  in  Nov./Dec.   +     Transac0ons  oSen  leSover  inventory   or  special  circumstances
  • 16. Machine  Learning  Specializa0on  16   An example detrending Model: yi = w0 + w1 ti + w2 sin(2πti / 12 - Φ) + εi ©2015  Emily  Fox  &  Carlos  Guestrin   Linear trend Seasonal component = Sinusoid with period 12 (resets annually) Unknown phase/shift Trigonometric identity: sin(a-b)=sin(a)cos(b)-cos(a)sin(b) à sin(2πti / 12 - Φ) = sin(2πti / 12)cos(Φ) - cos(2πti / 12)sin(Φ)
  • 17. Machine  Learning  Specializa0on  17   An example detrending Equivalently, yi = w0 + w1 ti + w2 sin(2πti / 12) + w3 cos(2πti / 12) + εi feature 1 = 1 (constant) feature 2 = t feature 3 = sin(2πt/12) feature 4 = cos(2πt/12) ©2015  Emily  Fox  &  Carlos  Guestrin  
  • 18. Machine  Learning  Specializa0on  18   11.512.012.513.013.514.0 Month log(Price) 1997−01 1999−01 2001−01 2003−01 2005−01 2007−01 2009−01 2011−01 2013−01 Detrended housing data Fit polynomial trend and sinusoidal seasonal component ©2015  Emily  Fox  &  Carlos  Guestrin   5th order polynomial + sin/cos basis
  • 19. Machine  Learning  Specializa0on  19   Zoom in… Fit polynomial trend and sinusoidal seasonal component ©2015  Emily  Fox  &  Carlos  Guestrin   5th order polynomial + sin/cos basis
  • 20. Machine  Learning  Specializa0on  20   Other examples of seasonality ©2015  Emily  Fox  &  Carlos  Guestrin   Weather modeling (e.g., temperature, rainfall) Demand forecasting (e.g., jacket purchases) Motion capture data Flu monitoring
  • 21. Machine  Learning  Specializa0on   More generally… ©2015  Emily  Fox  &  Carlos  Guestrin  
  • 22. Machine  Learning  Specializa0on  22   Generic basis expansion Model: yi = w0h0(xi) + w1 h1(xi) + … + wD hD(xi)+ εi = wj hj(xi) + εi feature 1 = h0(x)…often 1 feature 2 = h1(x)… e.g., x feature 3 = h2(x)… e.g., x2 or sin(2πx/12) … feature p+1 = hp(x)… e.g., xp ©2015  Emily  Fox  &  Carlos  Guestrin   jth regression coefficient or weight jth feature DX j=0
  • 23. Machine  Learning  Specializa0on  23   Generic basis expansion Model: yi = w0h0(xi) + w1 h1(xi) + … + wD hD(xi)+ εi = wj hj(xi) + εi feature 1 = h0(x)…often 1 (constant) feature 2 = h1(x)… e.g., x feature 3 = h2(x)… e.g., x2 or sin(2πx/12) … feature D+1 = hD(x)… e.g., xp ©2015  Emily  Fox  &  Carlos  Guestrin   DX j=0
  • 24. Machine  Learning  Specializa0on  24   ©2015  Emily  Fox  &  Carlos  Guestrin   Training Data Feature extraction ML model Quality metric ML algorithm y x ŷ ŵ x h(x)
  • 25. Machine  Learning  Specializa0on   Incorporating multiple inputs ©2015  Emily  Fox  &  Carlos  Guestrin  
  • 26. Machine  Learning  Specializa0on  26   Predictions just based on house size ©2015  Emily  Fox  &  Carlos  Guestrin   square feet (sq.ft.) price($) x y Only 1 bathroom! Not same as my 3 bathrooms
  • 27. Machine  Learning  Specializa0on  27   Add more inputs ©2015  Emily  Fox  &  Carlos  Guestrin   square feet (sq.ft.) price($) x[1] y x[2] f(x) = w0 + w1 sq.ft. + w2 #bath
  • 28. Machine  Learning  Specializa0on  28   Many possible inputs - Square feet - # bathrooms - # bedrooms - Lot size - Year built - … ©2015  Emily  Fox  &  Carlos  Guestrin  
  • 29. Machine  Learning  Specializa0on  29   Reading your mind ©2015  Emily  Fox  &  Carlos  Guestrin   very sad very happy Features are brain region intensities
  • 30. Machine  Learning  Specializa0on  30   General notation Output: y Inputs: x = (x[1],x[2],…, x[d]) Notational conventions: x[j] = jth input (scalar) hj(x) = jth feature (scalar) xi = input of ith data point (vector) xi[j] = jth input of ith data point (scalar) ©2015  Emily  Fox  &  Carlos  Guestrin   d-dim vector scalar
  • 31. Machine  Learning  Specializa0on  31   Simple hyperplane ©2015  Emily  Fox  &  Carlos  Guestrin   Model: yi = w0 + w1 xi[1] + … + wd xi[d] + εi feature 1 = 1 feature 2 = x[1] … e.g., sq. ft. feature 3 = x[2] … e.g., #bath … feature d+1 = x[d] … e.g., lot size
  • 32. Machine  Learning  Specializa0on  32   More generically… D-dimensional curve ©2015  Emily  Fox  &  Carlos  Guestrin   Model: yi = w0 h0(xi) + w1 h1(xi) + … + wD hD(xi) + εi = wj hj(xi) + εi feature 1 = h0(x) … e.g., 1 feature 2 = h1(x) … e.g., x[1] = sq. ft. feature 3 = h2(x) … e.g., x[2] = #bath or, log(x[7]) x[2] = log(#bed) x #bath … feature D+1 = hD(x) … some other function of x[1],…, x[d] DX j=0
  • 33. Machine  Learning  Specializa0on  33   More on notation # observations (xi,yi) : N # inputs x[j] : d # features hj(x) : D ©2015  Emily  Fox  &  Carlos  Guestrin  
  • 34. Machine  Learning  Specializa0on   Interpreting the fitted function ©2015  Emily  Fox  &  Carlos  Guestrin  
  • 35. Machine  Learning  Specializa0on  35   ©2015  Emily  Fox  &  Carlos  Guestrin   square feet (sq.ft.) price($) x y Interpreting the coefficients – Simple linear regression ŷ = ŵ0 + ŵ1 x 1 sq. ft. predicted change in $
  • 36. Machine  Learning  Specializa0on  36   fix ©2015  Emily  Fox  &  Carlos  Guestrin   Interpreting the coefficients – Two linear features square feet (sq.ft.) price($) x[1] y x[2] ŷ = ŵ0 + ŵ1 x[1] + ŵ2 x[2]
  • 37. Machine  Learning  Specializa0on  37   fix ©2015  Emily  Fox  &  Carlos  Guestrin   Interpreting the coefficients – Two linear features ŷ = ŵ0 + ŵ1 x[1] + ŵ2 x[2] # bathrooms price($) x[2] 1 bathroom predicted change in $ y For fixed # sq.ft.!
  • 38. Machine  Learning  Specializa0on  38   fix fix fixfix ©2015  Emily  Fox  &  Carlos  Guestrin   Interpreting the coefficients – Multiple linear features ŷ = ŵ0 + ŵ1 x[1] + …+ŵj x[j] + … + ŵd x[d] square feet (sq.ft.) price($) x[1] y x[2]
  • 39. Machine  Learning  Specializa0on  39   ©2015  Emily  Fox  &  Carlos  Guestrin   Interpreting the coefficients- Polynomial regression ŷ = ŵ0 + ŵ1x +… + ŵj xj + … + ŵp xp square feet (sq.ft.) price($) x y Can’t hold other features fixed!
  • 40. Machine  Learning  Specializa0on   Fitting D-dimensional curves ©2015  Emily  Fox  &  Carlos  Guestrin  
  • 41. Machine  Learning  Specializa0on  41   ©2015  Emily  Fox  &  Carlos  Guestrin   Training Data Feature extraction ML model Quality metric ML algorithm ŵy ŷh(x)
  • 42. Machine  Learning  Specializa0on   Step 1: Rewrite the regression model ©2015  Emily  Fox  &  Carlos  Guestrin  
  • 43. Machine  Learning  Specializa0on  43   Rewrite in matrix notation For observation i ©2015  Emily  Fox  &  Carlos  Guestrin   yi = wj hj(xi) + εi = + εiyi DX j=0 = + εi
  • 44. Machine  Learning  Specializa0on  44   Rewrite in matrix notation For all observations together ©2015  Emily  Fox  &  Carlos  Guestrin   = +
  • 45. Machine  Learning  Specializa0on   Step 2: Compute the cost ©2015  Emily  Fox  &  Carlos  Guestrin  
  • 46. Machine  Learning  Specializa0on  46   ©2015  Emily  Fox  &  Carlos  Guestrin   Training Data Feature extraction ML model Quality metric ML algorithm y h(x) ŷ ŵ
  • 47. Machine  Learning  Specializa0on  47   “Cost” of using a given line ©2015  Emily  Fox  &  Carlos  Guestrin   square feet (sq.ft.) price($) x y Residual sum of squares (RSS) RSS(w0,w1) = (yi-[w0+w1xi])2
  • 48. Machine  Learning  Specializa0on  48   RSS for multiple regression ©2015  Emily  Fox  &  Carlos  Guestrin   square feet (sq.ft.) price($) y RSS(w) = (yi- )2 x[1] x[2] ŷi =
  • 49. Machine  Learning  Specializa0on  49   RSS in matrix notation ©2015  Emily  Fox  &  Carlos  Guestrin   RSS(w) = (yi- h(xi)Tw)2 = Why? (part 1)
  • 50. Machine  Learning  Specializa0on  50   RSS in matrix notation ©2015  Emily  Fox  &  Carlos  Guestrin   RSS(w) = (yi- h(xi)Tw)2 = (y-Hw)T(y-Hw) residual1 residual2 residual3 … residualN residual1 residual2 residual3 … residualN = Why? (part 2)
  • 51. Machine  Learning  Specializa0on   Step 3: Take the gradient ©2015  Emily  Fox  &  Carlos  Guestrin  
  • 52. Machine  Learning  Specializa0on  52   Gradient of RSS ©2015  Emily  Fox  &  Carlos  Guestrin   RSS(w) = [(y-Hw)T(y-Hw)] = -2HT(y-Hw) Δ Δ Why? By analogy to 1D case:
  • 53. Machine  Learning  Specializa0on   Step 4, Approach 1: Set the gradient = 0 ©2015  Emily  Fox  &  Carlos  Guestrin  
  • 54. Machine  Learning  Specializa0on  54   Closed-form solution ©2015  Emily  Fox  &  Carlos  Guestrin   RSS(w) = -2HT(y-Hw) = 0 Δ Solve for w:
  • 55. Machine  Learning  Specializa0on  55   Closed-form solution ©2015  Emily  Fox  &  Carlos  Guestrin   ŵ = ( HTH )-1 HTy Invertible if: Complexity of inverse:
  • 56. Machine  Learning  Specializa0on   Step 4, Approach 2: Gradient descent ©2015  Emily  Fox  &  Carlos  Guestrin  
  • 57. Machine  Learning  Specializa0on  57   Gradient descent ©2015  Emily  Fox  &  Carlos  Guestrin   while not converged w(t+1) ß w(t) - η RSS(w(t)) Δ -2HT(y-Hw)
  • 58. Machine  Learning  Specializa0on  58   Feature-by-feature update ©2015  Emily  Fox  &  Carlos  Guestrin   RSS(w) = (yi- h(xi)Tw)2 Partial with respect to wj wj (t+1) ß wj (t) - η( ) Update to jth feature weight:
  • 59. Machine  Learning  Specializa0on  59   Interpreting elementwise ©2015  Emily  Fox  &  Carlos  Guestrin   wj (t+1) ß wj (t) + 2η hj(xi)(yi-ŷi(w(t))) Update to jth feature weight: square feet (sq.ft.) price($) y x[1] x[2]
  • 60. Machine  Learning  Specializa0on  60   Summary of gradient descent for multiple regression ©2015  Emily  Fox  &  Carlos  Guestrin   init w(1)=0 (or randomly, or smartly), t=1 while || RSS(w(t))|| > ε for j=0,…,D partial[j] =-2 hj(xi)(yi-ŷi(w(t))) wj (t+1) ß wj (t) – η partial[j] t ß t + 1 Δ
  • 61. Machine  Learning  Specializa0on  62   An extremely useful algorithm ©2015  Emily  Fox  &  Carlos  Guestrin  
  • 62. Machine  Learning  Specializa0on   Summary for multiple linear regression ©2015  Emily  Fox  &  Carlos  Guestrin  
  • 63. Machine  Learning  Specializa0on  64   What you can do now… •  Describe polynomial regression •  Detrend a time series using trend and seasonal components •  Write a regression model using multiple inputs or features thereof •  Cast both polynomial regression and regression with multiple inputs as regression with multiple features •  Calculate a goodness-of-fit metric (e.g., RSS) •  Estimate model parameters of a general multiple regression model to minimize RSS: -  In closed form -  Using an iterative gradient descent algorithm •  Interpret the coefficients of a non-featurized multiple regression fit •  Exploit the estimated model to form predictions •  Explain applications of multiple regression beyond house price modeling ©2015  Emily  Fox  &  Carlos  Guestrin