SlideShare a Scribd company logo
COPYRIGHT 2017, THE UNIVERSITY OF MELBOURNE
Workshop Week 03
COMP90051
COPYRIGHT 2017, THE UNIVERSITY OF MELBOURNE
About the Workshops
7 sessions in total
Tue 12:00-13:00 AH211
Tue 12:00-13:00 AH108 *
Tue 13:00-14:00 AH210
Tue 16:15-17:15 AH109
Tue 17:15-18:15 AH236 *
Tue 18:15-19:15 AH236 *
Fri 14:15-15:15 AH211
COPYRIGHT 2017, THE UNIVERSITY OF MELBOURNE
About the Workshops
Homepage
https://trevorcohn.github.io/comp90051-2017/workshops
Solutions have been released.
COPYRIGHT 2017, THE UNIVERSITY OF MELBOURNE
Outline
Review the lecture, background knowledge, etc.
Model evaluation, selection, optimization
Regularizor as a prior
Jupyter Usage
Notebook tasks
Task 1: Linear regression
Task 2: Polynominal regression
COPYRIGHT 2017, THE UNIVERSITY OF MELBOURNE
Outline
Review the lecture, background knowledge, etc.
Model evaluation, selection, optimization
Regularizor as a prior
Jupyter Usage
Notebook tasks
Task 1: Linear regression
Task 2: Polynominal regression
COPYRIGHT 2017, THE UNIVERSITY OF MELBOURNE
Model Evaluation
Model
Evaluation
Metric
�
𝒚𝒚
𝑿𝑿
𝒚𝒚
Score
COPYRIGHT 2017, THE UNIVERSITY OF MELBOURNE
What could the output be?
Regression
A value
A distribution
Classification
A label
A value (binary) / values (multi-class)
A distribution
COMP90051 Machine Learning (S2 2017) L1
Types of models
8
�
𝑦𝑦 = 𝑓𝑓 𝑥𝑥
KT mark was 95, ML
mark is predicted to be
95
𝑃𝑃 𝑦𝑦 𝑥𝑥
KT mark was 95, ML
mark is likely to be in
(92, 97)
𝑃𝑃(𝑥𝑥, 𝑦𝑦)
probability of having
(𝐾𝐾𝐾𝐾 = 𝑥𝑥, 𝑀𝑀𝑀𝑀 = 𝑦𝑦)
𝑥𝑥
COPYRIGHT 2017, THE UNIVERSITY OF MELBOURNE
http://scikit-learn.org/0.17/auto_examples/gaussian_process/plot_gp_regression.html
COPYRIGHT 2017, THE UNIVERSITY OF MELBOURNE
https://www.tensorflow.org/tutorials/image_recognition
COPYRIGHT 2017, THE UNIVERSITY OF MELBOURNE
http://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html
COPYRIGHT 2017, THE UNIVERSITY OF MELBOURNE
Model Evaluation
Regression
RMSE, MAE, etc.
Classification
Accuracy, precision, recall, f-score, etc.
Log-loss (a.k.a. cross entropy), likelihood, etc.
Model
Evaluation
Metric
�
𝒚𝒚
𝑿𝑿
𝒚𝒚
Score
COPYRIGHT 2017, THE UNIVERSITY OF MELBOURNE
Model Selection
Model 1
Selection
Criteria
�
𝒚𝒚
𝑿𝑿
𝒚𝒚
Score 1
Model 2
Selection
Criteria
�
𝒚𝒚
𝑿𝑿
𝒚𝒚
Score 2
COPYRIGHT 2017, THE UNIVERSITY OF MELBOURNE
Model Optimization
The evaluation metric & the objective function may differ
Could be entirely different
Or additional terms in the objective function, e.g. L1/L2
Model
Objective
Function
�
𝒚𝒚
𝑿𝑿
𝒚𝒚
Score
optimize parameters
parameters
COPYRIGHT 2017, THE UNIVERSITY OF MELBOURNE
More on the objective function
Maximize the likelihood (or log likelihood)
max
𝒘𝒘
𝑝𝑝(𝒚𝒚|𝑿𝑿, 𝒘𝒘)  max
𝒘𝒘
∏ 𝑝𝑝(𝑦𝑦𝑖𝑖|𝒙𝒙𝑖𝑖, 𝒘𝒘)  max
𝒘𝒘
∑ log 𝑝𝑝(𝑦𝑦𝑖𝑖|𝒙𝒙𝑖𝑖, 𝒘𝒘)
Maximize the posterior (a.k.a. max a posteriori, MAP)
max
𝒘𝒘
𝑝𝑝(𝒘𝒘|𝑿𝑿, 𝒚𝒚)  max
𝒘𝒘
𝑝𝑝 𝒚𝒚 𝑿𝑿, 𝒘𝒘 𝑝𝑝(𝒘𝒘) (assume 𝒘𝒘 ⊥ 𝑿𝑿)
Minimize the loss function (+regularization)
min
𝒘𝒘
∑ 𝐿𝐿(𝑓𝑓 𝒙𝒙𝑖𝑖; 𝒘𝒘 , 𝑦𝑦𝑖𝑖) or min
𝒘𝒘
∑ 𝐿𝐿(𝑓𝑓 𝒙𝒙𝑖𝑖; 𝒘𝒘 , 𝑦𝑦𝑖𝑖) + 𝜆𝜆𝜆𝜆(𝒘𝒘)
Minimize the log-loss (a.k.a. cross entropy) (+L1/L2)
Minimize the hinge-loss (+L2)
Minimize the mean squared error (+L1/L2)
COPYRIGHT 2017, THE UNIVERSITY OF MELBOURNE
More on the objective function
Maximize the likelihood (or log likelihood)
max
𝒘𝒘
𝑝𝑝(𝒚𝒚|𝑿𝑿, 𝒘𝒘)  max
𝒘𝒘
∏ 𝑝𝑝(𝑦𝑦𝑖𝑖|𝒙𝒙𝑖𝑖, 𝒘𝒘)  max
𝒘𝒘
∑ log 𝑝𝑝(𝑦𝑦𝑖𝑖|𝒙𝒙𝑖𝑖, 𝒘𝒘)
Maximize the posterior (a.k.a. max a posteriori, MAP)
max
𝒘𝒘
𝑝𝑝(𝒘𝒘|𝑿𝑿, 𝒚𝒚)  max
𝒘𝒘
𝑝𝑝 𝒚𝒚 𝑿𝑿, 𝒘𝒘 𝑝𝑝(𝒘𝒘) (assume 𝒘𝒘 ⊥ 𝑿𝑿)
Minimize the loss function (+regularization)
min
𝒘𝒘
∑ 𝐿𝐿(𝑓𝑓 𝒙𝒙𝑖𝑖; 𝒘𝒘 , 𝑦𝑦𝑖𝑖) or min
𝒘𝒘
∑ 𝐿𝐿(𝑓𝑓 𝒙𝒙𝑖𝑖; 𝒘𝒘 , 𝑦𝑦𝑖𝑖) + 𝜆𝜆𝜆𝜆(𝒘𝒘)
Minimize the log-loss (a.k.a. cross entropy) (+L1/L2)
Minimize the hinge-loss (+L2)
Minimize the mean squared error (+L1/L2)
COPYRIGHT 2017, THE UNIVERSITY OF MELBOURNE
Outline
Review the lecture, background knowledge, etc.
Model evaluation, selection, optimization
Regularizor as a prior
Jupyter Usage
Notebook tasks
Task 1: Linear regression
Task 2: Polynominal regression
Statistical Machine Learning (S2 2017) Deck 3
Regulariser as a prior
• Without regularisation model parameters are found
based entirely on the information contained in the
training set 𝑿𝑿
• Regularisation essentially means introducing additional
information
• Recall our probabilistic model 𝒴𝒴 = 𝒙𝒙′
𝒘𝒘 + 𝜀𝜀
∗ Here 𝒴𝒴 and 𝜀𝜀 are random variables, where 𝜀𝜀 denotes noise
• Now suppose that 𝒘𝒘 is also a random variable (denoted
as 𝒲𝒲) with a normal prior distribution
𝒲𝒲~𝒩𝒩 0, 𝜆𝜆2
18
Statistical Machine Learning (S2 2017) Deck 3
Computing posterior using Bayes rule
• The prior is then used to compute the posterior
𝑝𝑝 𝒘𝒘|𝑿𝑿, 𝒚𝒚 =
𝑝𝑝 𝒚𝒚|𝑿𝑿, 𝒘𝒘 𝑝𝑝 𝒘𝒘
𝑝𝑝 𝒚𝒚|𝑿𝑿
• Instead of maximum likelihood (MLE), take maximum a posteriori
estimate (MAP)
• Apply log trick, so that
log 𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝 = log 𝑙𝑙𝑙𝑙𝑙𝑙𝑙𝑙𝑙𝑙𝑙𝑙𝑙𝑙𝑙𝑙𝑙𝑙𝑙 + log 𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝 − log 𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚
• Arrive at the problem of minimising
𝒚𝒚 − 𝑿𝑿𝑿𝑿 2
2
+ 𝜆𝜆 𝒘𝒘 2
2
19
posterior
likelihood prior
marginal
likelihood
this term doesn’t
affect optimisation
COPYRIGHT 2017, THE UNIVERSITY OF MELBOURNE
Outline
Review the lecture, background knowledge, etc.
Model evaluation, selection, optimization
Regularizor as a prior
Jupyter Usage
Notebook tasks
Task 1: Linear regression
Task 2: Polynominal regression
COPYRIGHT 2017, THE UNIVERSITY OF MELBOURNE
Keyboard Shortcuts
COPYRIGHT 2017, THE UNIVERSITY OF MELBOURNE
Outline
Review the lecture, background knowledge, etc.
Model evaluation, selection, optimization
Regularizor as a prior
Jupyter Usage
Notebook tasks
Task 1: Linear regression
Task 2: Polynomial regression
COPYRIGHT 2017, THE UNIVERSITY OF MELBOURNE
Linear regression
𝑥𝑥1 → 𝑦𝑦1, 𝑥𝑥2 → 𝑦𝑦2, 𝑥𝑥3 → 𝑦𝑦3, 𝑥𝑥4 → 𝑦𝑦4

1 𝑥𝑥1
1 𝑥𝑥2
1 𝑥𝑥3
1 𝑥𝑥4
𝑤𝑤0
𝑤𝑤1
=
�
𝑦𝑦1
�
𝑦𝑦2
�
𝑦𝑦3
�
𝑦𝑦4
Minimize the objective function
1
4
∑𝑖𝑖=1
4
�
𝑦𝑦𝑖𝑖 − 𝑦𝑦𝑖𝑖
2
or
1
4
∑𝑖𝑖=1
4
�
𝑦𝑦𝑖𝑖 − 𝑦𝑦𝑖𝑖
2
+ 𝜆𝜆 ∑𝑗𝑗=0
1
𝑤𝑤𝑗𝑗
2
Analytic solution & iterative solution
COPYRIGHT 2017, THE UNIVERSITY OF MELBOURNE
Multivariate linear regression (2-D points)
 𝑥𝑥1,1, 𝑥𝑥1,2 → 𝑦𝑦1, 𝑥𝑥2,1, 𝑥𝑥2,2 → 𝑦𝑦2
 𝑥𝑥3,1, 𝑥𝑥3,2 → 𝑦𝑦3, 𝑥𝑥4,1, 𝑥𝑥4,2 → 𝑦𝑦4

1 𝑥𝑥1,1 𝑥𝑥1,2
1 𝑥𝑥2,1 𝑥𝑥2,2
1 𝑥𝑥3,1 𝑥𝑥3,2
1 𝑥𝑥4,1 𝑥𝑥4,2
𝑤𝑤0
𝑤𝑤1
𝑤𝑤2
=
�
𝑦𝑦1
�
𝑦𝑦2
�
𝑦𝑦3
�
𝑦𝑦4
Minimize the objective function
1
4
∑𝑖𝑖=1
4
�
𝑦𝑦𝑖𝑖 − 𝑦𝑦𝑖𝑖
2
or
1
4
∑𝑖𝑖=1
4
�
𝑦𝑦𝑖𝑖 − 𝑦𝑦𝑖𝑖
2
+ 𝜆𝜆 ∑𝑗𝑗=0
2
𝑤𝑤𝑗𝑗
2
Analytic solution & iterative solution
COPYRIGHT 2017, THE UNIVERSITY OF MELBOURNE
Polynomial regression (Quadratic)
𝑥𝑥1 → 𝑦𝑦1, 𝑥𝑥2 → 𝑦𝑦2, 𝑥𝑥3 → 𝑦𝑦3, 𝑥𝑥4 → 𝑦𝑦4

1 𝑥𝑥1 𝑥𝑥1
2
1 𝑥𝑥2 𝑥𝑥2
2
1 𝑥𝑥3 𝑥𝑥3
2
1 𝑥𝑥4 𝑥𝑥4
2
𝑤𝑤0
𝑤𝑤1
𝑤𝑤2
=
�
𝑦𝑦1
�
𝑦𝑦2
�
𝑦𝑦3
�
𝑦𝑦4
Minimize the objective function
1
4
∑𝑖𝑖=1
4
�
𝑦𝑦𝑖𝑖 − 𝑦𝑦𝑖𝑖
2
or
1
4
∑𝑖𝑖=1
4
�
𝑦𝑦𝑖𝑖 − 𝑦𝑦𝑖𝑖
2
+ 𝜆𝜆 ∑𝑗𝑗=0
2
𝑤𝑤𝑗𝑗
2
Analytic solution & iterative solution

More Related Content

Similar to 2017S2_SML_Week03.pdf

Linear, Machine Learning or Probabilistic Predictive Models: What's Best for ...
Linear, Machine Learning or Probabilistic Predictive Models: What's Best for ...Linear, Machine Learning or Probabilistic Predictive Models: What's Best for ...
Linear, Machine Learning or Probabilistic Predictive Models: What's Best for ...
Bohdan Pavlyshenko
 
Developing Computational Skills in the Sciences with Matlab Webinar 2017
Developing Computational Skills in the Sciences with Matlab Webinar 2017Developing Computational Skills in the Sciences with Matlab Webinar 2017
Developing Computational Skills in the Sciences with Matlab Webinar 2017
SERC at Carleton College
 
Incremental View Maintenance for openCypher Queries
Incremental View Maintenance for openCypher QueriesIncremental View Maintenance for openCypher Queries
Incremental View Maintenance for openCypher Queries
Gábor Szárnyas
 
Incremental View Maintenance for openCypher Queries
Incremental View Maintenance for openCypher QueriesIncremental View Maintenance for openCypher Queries
Incremental View Maintenance for openCypher Queries
openCypher
 
Ds33717725
Ds33717725Ds33717725
Ds33717725
IJERA Editor
 
Ds33717725
Ds33717725Ds33717725
Ds33717725
IJERA Editor
 
Asymptotic Analysis
Asymptotic AnalysisAsymptotic Analysis
Asymptotic Analysis
sonugupta
 
Matlab for Chemical Engineering
Matlab for Chemical EngineeringMatlab for Chemical Engineering
Matlab for Chemical Engineering
Debarun Banerjee
 
Session 4 .pdf
Session 4 .pdfSession 4 .pdf
Session 4 .pdf
ssuser8cda84
 
"Incremental Lossless Graph Summarization", KDD 2020
"Incremental Lossless Graph Summarization", KDD 2020"Incremental Lossless Graph Summarization", KDD 2020
"Incremental Lossless Graph Summarization", KDD 2020
지훈 고
 
A Reinforcement Learning Approach for Hybrid Flexible Flowline Scheduling Pro...
A Reinforcement Learning Approach for Hybrid Flexible Flowline Scheduling Pro...A Reinforcement Learning Approach for Hybrid Flexible Flowline Scheduling Pro...
A Reinforcement Learning Approach for Hybrid Flexible Flowline Scheduling Pro...
Bert Van Vreckem
 
Diseño rapido de amplificadores con valores
Diseño rapido de amplificadores con valoresDiseño rapido de amplificadores con valores
Diseño rapido de amplificadores con valores
Félix Chávez
 
Intro to statistical signal processing
Intro to statistical signal processingIntro to statistical signal processing
Intro to statistical signal processing
Nadav Carmel
 
OptimumEngineeringDesign-Day-1.pdf
OptimumEngineeringDesign-Day-1.pdfOptimumEngineeringDesign-Day-1.pdf
OptimumEngineeringDesign-Day-1.pdf
SantiagoGarridoBulln
 
Sampling method : MCMC
Sampling method : MCMCSampling method : MCMC
Sampling method : MCMC
SEMINARGROOT
 
On the Configuration-LP of the Restricted Assignment Problem
On the Configuration-LP of the Restricted Assignment ProblemOn the Configuration-LP of the Restricted Assignment Problem
On the Configuration-LP of the Restricted Assignment Problem
Arash Pourdamghani
 
Final Presentation
Final PresentationFinal Presentation
Final Presentation
Benjamin Johnson
 
Parallel Bayesian Optimization
Parallel Bayesian OptimizationParallel Bayesian Optimization
Parallel Bayesian Optimization
Sri Ambati
 
Algorithms Lab PPT
Algorithms Lab PPTAlgorithms Lab PPT
Algorithms Lab PPT
Abhishek Chandra
 
Expectation maximization
Expectation maximizationExpectation maximization
Expectation maximization
LALAOUIBENCHERIFSIDI
 

Similar to 2017S2_SML_Week03.pdf (20)

Linear, Machine Learning or Probabilistic Predictive Models: What's Best for ...
Linear, Machine Learning or Probabilistic Predictive Models: What's Best for ...Linear, Machine Learning or Probabilistic Predictive Models: What's Best for ...
Linear, Machine Learning or Probabilistic Predictive Models: What's Best for ...
 
Developing Computational Skills in the Sciences with Matlab Webinar 2017
Developing Computational Skills in the Sciences with Matlab Webinar 2017Developing Computational Skills in the Sciences with Matlab Webinar 2017
Developing Computational Skills in the Sciences with Matlab Webinar 2017
 
Incremental View Maintenance for openCypher Queries
Incremental View Maintenance for openCypher QueriesIncremental View Maintenance for openCypher Queries
Incremental View Maintenance for openCypher Queries
 
Incremental View Maintenance for openCypher Queries
Incremental View Maintenance for openCypher QueriesIncremental View Maintenance for openCypher Queries
Incremental View Maintenance for openCypher Queries
 
Ds33717725
Ds33717725Ds33717725
Ds33717725
 
Ds33717725
Ds33717725Ds33717725
Ds33717725
 
Asymptotic Analysis
Asymptotic AnalysisAsymptotic Analysis
Asymptotic Analysis
 
Matlab for Chemical Engineering
Matlab for Chemical EngineeringMatlab for Chemical Engineering
Matlab for Chemical Engineering
 
Session 4 .pdf
Session 4 .pdfSession 4 .pdf
Session 4 .pdf
 
"Incremental Lossless Graph Summarization", KDD 2020
"Incremental Lossless Graph Summarization", KDD 2020"Incremental Lossless Graph Summarization", KDD 2020
"Incremental Lossless Graph Summarization", KDD 2020
 
A Reinforcement Learning Approach for Hybrid Flexible Flowline Scheduling Pro...
A Reinforcement Learning Approach for Hybrid Flexible Flowline Scheduling Pro...A Reinforcement Learning Approach for Hybrid Flexible Flowline Scheduling Pro...
A Reinforcement Learning Approach for Hybrid Flexible Flowline Scheduling Pro...
 
Diseño rapido de amplificadores con valores
Diseño rapido de amplificadores con valoresDiseño rapido de amplificadores con valores
Diseño rapido de amplificadores con valores
 
Intro to statistical signal processing
Intro to statistical signal processingIntro to statistical signal processing
Intro to statistical signal processing
 
OptimumEngineeringDesign-Day-1.pdf
OptimumEngineeringDesign-Day-1.pdfOptimumEngineeringDesign-Day-1.pdf
OptimumEngineeringDesign-Day-1.pdf
 
Sampling method : MCMC
Sampling method : MCMCSampling method : MCMC
Sampling method : MCMC
 
On the Configuration-LP of the Restricted Assignment Problem
On the Configuration-LP of the Restricted Assignment ProblemOn the Configuration-LP of the Restricted Assignment Problem
On the Configuration-LP of the Restricted Assignment Problem
 
Final Presentation
Final PresentationFinal Presentation
Final Presentation
 
Parallel Bayesian Optimization
Parallel Bayesian OptimizationParallel Bayesian Optimization
Parallel Bayesian Optimization
 
Algorithms Lab PPT
Algorithms Lab PPTAlgorithms Lab PPT
Algorithms Lab PPT
 
Expectation maximization
Expectation maximizationExpectation maximization
Expectation maximization
 

Recently uploaded

คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
สมใจ จันสุกสี
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
TechSoup
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
Nguyen Thanh Tu Collection
 
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptxNEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
iammrhaywood
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
Dr. Mulla Adam Ali
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Fajar Baskoro
 
Reimagining Your Library Space: How to Increase the Vibes in Your Library No ...
Reimagining Your Library Space: How to Increase the Vibes in Your Library No ...Reimagining Your Library Space: How to Increase the Vibes in Your Library No ...
Reimagining Your Library Space: How to Increase the Vibes in Your Library No ...
Diana Rendina
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptxBeyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
EduSkills OECD
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience
Wahiba Chair Training & Consulting
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skillsspot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
haiqairshad
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 

Recently uploaded (20)

คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
 
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptxNEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
 
Reimagining Your Library Space: How to Increase the Vibes in Your Library No ...
Reimagining Your Library Space: How to Increase the Vibes in Your Library No ...Reimagining Your Library Space: How to Increase the Vibes in Your Library No ...
Reimagining Your Library Space: How to Increase the Vibes in Your Library No ...
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptxBeyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skillsspot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 

2017S2_SML_Week03.pdf

  • 1. COPYRIGHT 2017, THE UNIVERSITY OF MELBOURNE Workshop Week 03 COMP90051
  • 2. COPYRIGHT 2017, THE UNIVERSITY OF MELBOURNE About the Workshops 7 sessions in total Tue 12:00-13:00 AH211 Tue 12:00-13:00 AH108 * Tue 13:00-14:00 AH210 Tue 16:15-17:15 AH109 Tue 17:15-18:15 AH236 * Tue 18:15-19:15 AH236 * Fri 14:15-15:15 AH211
  • 3. COPYRIGHT 2017, THE UNIVERSITY OF MELBOURNE About the Workshops Homepage https://trevorcohn.github.io/comp90051-2017/workshops Solutions have been released.
  • 4. COPYRIGHT 2017, THE UNIVERSITY OF MELBOURNE Outline Review the lecture, background knowledge, etc. Model evaluation, selection, optimization Regularizor as a prior Jupyter Usage Notebook tasks Task 1: Linear regression Task 2: Polynominal regression
  • 5. COPYRIGHT 2017, THE UNIVERSITY OF MELBOURNE Outline Review the lecture, background knowledge, etc. Model evaluation, selection, optimization Regularizor as a prior Jupyter Usage Notebook tasks Task 1: Linear regression Task 2: Polynominal regression
  • 6. COPYRIGHT 2017, THE UNIVERSITY OF MELBOURNE Model Evaluation Model Evaluation Metric � 𝒚𝒚 𝑿𝑿 𝒚𝒚 Score
  • 7. COPYRIGHT 2017, THE UNIVERSITY OF MELBOURNE What could the output be? Regression A value A distribution Classification A label A value (binary) / values (multi-class) A distribution
  • 8. COMP90051 Machine Learning (S2 2017) L1 Types of models 8 � 𝑦𝑦 = 𝑓𝑓 𝑥𝑥 KT mark was 95, ML mark is predicted to be 95 𝑃𝑃 𝑦𝑦 𝑥𝑥 KT mark was 95, ML mark is likely to be in (92, 97) 𝑃𝑃(𝑥𝑥, 𝑦𝑦) probability of having (𝐾𝐾𝐾𝐾 = 𝑥𝑥, 𝑀𝑀𝑀𝑀 = 𝑦𝑦) 𝑥𝑥
  • 9. COPYRIGHT 2017, THE UNIVERSITY OF MELBOURNE http://scikit-learn.org/0.17/auto_examples/gaussian_process/plot_gp_regression.html
  • 10. COPYRIGHT 2017, THE UNIVERSITY OF MELBOURNE https://www.tensorflow.org/tutorials/image_recognition
  • 11. COPYRIGHT 2017, THE UNIVERSITY OF MELBOURNE http://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html
  • 12. COPYRIGHT 2017, THE UNIVERSITY OF MELBOURNE Model Evaluation Regression RMSE, MAE, etc. Classification Accuracy, precision, recall, f-score, etc. Log-loss (a.k.a. cross entropy), likelihood, etc. Model Evaluation Metric � 𝒚𝒚 𝑿𝑿 𝒚𝒚 Score
  • 13. COPYRIGHT 2017, THE UNIVERSITY OF MELBOURNE Model Selection Model 1 Selection Criteria � 𝒚𝒚 𝑿𝑿 𝒚𝒚 Score 1 Model 2 Selection Criteria � 𝒚𝒚 𝑿𝑿 𝒚𝒚 Score 2
  • 14. COPYRIGHT 2017, THE UNIVERSITY OF MELBOURNE Model Optimization The evaluation metric & the objective function may differ Could be entirely different Or additional terms in the objective function, e.g. L1/L2 Model Objective Function � 𝒚𝒚 𝑿𝑿 𝒚𝒚 Score optimize parameters parameters
  • 15. COPYRIGHT 2017, THE UNIVERSITY OF MELBOURNE More on the objective function Maximize the likelihood (or log likelihood) max 𝒘𝒘 𝑝𝑝(𝒚𝒚|𝑿𝑿, 𝒘𝒘)  max 𝒘𝒘 ∏ 𝑝𝑝(𝑦𝑦𝑖𝑖|𝒙𝒙𝑖𝑖, 𝒘𝒘)  max 𝒘𝒘 ∑ log 𝑝𝑝(𝑦𝑦𝑖𝑖|𝒙𝒙𝑖𝑖, 𝒘𝒘) Maximize the posterior (a.k.a. max a posteriori, MAP) max 𝒘𝒘 𝑝𝑝(𝒘𝒘|𝑿𝑿, 𝒚𝒚)  max 𝒘𝒘 𝑝𝑝 𝒚𝒚 𝑿𝑿, 𝒘𝒘 𝑝𝑝(𝒘𝒘) (assume 𝒘𝒘 ⊥ 𝑿𝑿) Minimize the loss function (+regularization) min 𝒘𝒘 ∑ 𝐿𝐿(𝑓𝑓 𝒙𝒙𝑖𝑖; 𝒘𝒘 , 𝑦𝑦𝑖𝑖) or min 𝒘𝒘 ∑ 𝐿𝐿(𝑓𝑓 𝒙𝒙𝑖𝑖; 𝒘𝒘 , 𝑦𝑦𝑖𝑖) + 𝜆𝜆𝜆𝜆(𝒘𝒘) Minimize the log-loss (a.k.a. cross entropy) (+L1/L2) Minimize the hinge-loss (+L2) Minimize the mean squared error (+L1/L2)
  • 16. COPYRIGHT 2017, THE UNIVERSITY OF MELBOURNE More on the objective function Maximize the likelihood (or log likelihood) max 𝒘𝒘 𝑝𝑝(𝒚𝒚|𝑿𝑿, 𝒘𝒘)  max 𝒘𝒘 ∏ 𝑝𝑝(𝑦𝑦𝑖𝑖|𝒙𝒙𝑖𝑖, 𝒘𝒘)  max 𝒘𝒘 ∑ log 𝑝𝑝(𝑦𝑦𝑖𝑖|𝒙𝒙𝑖𝑖, 𝒘𝒘) Maximize the posterior (a.k.a. max a posteriori, MAP) max 𝒘𝒘 𝑝𝑝(𝒘𝒘|𝑿𝑿, 𝒚𝒚)  max 𝒘𝒘 𝑝𝑝 𝒚𝒚 𝑿𝑿, 𝒘𝒘 𝑝𝑝(𝒘𝒘) (assume 𝒘𝒘 ⊥ 𝑿𝑿) Minimize the loss function (+regularization) min 𝒘𝒘 ∑ 𝐿𝐿(𝑓𝑓 𝒙𝒙𝑖𝑖; 𝒘𝒘 , 𝑦𝑦𝑖𝑖) or min 𝒘𝒘 ∑ 𝐿𝐿(𝑓𝑓 𝒙𝒙𝑖𝑖; 𝒘𝒘 , 𝑦𝑦𝑖𝑖) + 𝜆𝜆𝜆𝜆(𝒘𝒘) Minimize the log-loss (a.k.a. cross entropy) (+L1/L2) Minimize the hinge-loss (+L2) Minimize the mean squared error (+L1/L2)
  • 17. COPYRIGHT 2017, THE UNIVERSITY OF MELBOURNE Outline Review the lecture, background knowledge, etc. Model evaluation, selection, optimization Regularizor as a prior Jupyter Usage Notebook tasks Task 1: Linear regression Task 2: Polynominal regression
  • 18. Statistical Machine Learning (S2 2017) Deck 3 Regulariser as a prior • Without regularisation model parameters are found based entirely on the information contained in the training set 𝑿𝑿 • Regularisation essentially means introducing additional information • Recall our probabilistic model 𝒴𝒴 = 𝒙𝒙′ 𝒘𝒘 + 𝜀𝜀 ∗ Here 𝒴𝒴 and 𝜀𝜀 are random variables, where 𝜀𝜀 denotes noise • Now suppose that 𝒘𝒘 is also a random variable (denoted as 𝒲𝒲) with a normal prior distribution 𝒲𝒲~𝒩𝒩 0, 𝜆𝜆2 18
  • 19. Statistical Machine Learning (S2 2017) Deck 3 Computing posterior using Bayes rule • The prior is then used to compute the posterior 𝑝𝑝 𝒘𝒘|𝑿𝑿, 𝒚𝒚 = 𝑝𝑝 𝒚𝒚|𝑿𝑿, 𝒘𝒘 𝑝𝑝 𝒘𝒘 𝑝𝑝 𝒚𝒚|𝑿𝑿 • Instead of maximum likelihood (MLE), take maximum a posteriori estimate (MAP) • Apply log trick, so that log 𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝 = log 𝑙𝑙𝑙𝑙𝑙𝑙𝑙𝑙𝑙𝑙𝑙𝑙𝑙𝑙𝑙𝑙𝑙𝑙𝑙 + log 𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝 − log 𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚 • Arrive at the problem of minimising 𝒚𝒚 − 𝑿𝑿𝑿𝑿 2 2 + 𝜆𝜆 𝒘𝒘 2 2 19 posterior likelihood prior marginal likelihood this term doesn’t affect optimisation
  • 20. COPYRIGHT 2017, THE UNIVERSITY OF MELBOURNE Outline Review the lecture, background knowledge, etc. Model evaluation, selection, optimization Regularizor as a prior Jupyter Usage Notebook tasks Task 1: Linear regression Task 2: Polynominal regression
  • 21. COPYRIGHT 2017, THE UNIVERSITY OF MELBOURNE Keyboard Shortcuts
  • 22. COPYRIGHT 2017, THE UNIVERSITY OF MELBOURNE Outline Review the lecture, background knowledge, etc. Model evaluation, selection, optimization Regularizor as a prior Jupyter Usage Notebook tasks Task 1: Linear regression Task 2: Polynomial regression
  • 23. COPYRIGHT 2017, THE UNIVERSITY OF MELBOURNE Linear regression 𝑥𝑥1 → 𝑦𝑦1, 𝑥𝑥2 → 𝑦𝑦2, 𝑥𝑥3 → 𝑦𝑦3, 𝑥𝑥4 → 𝑦𝑦4  1 𝑥𝑥1 1 𝑥𝑥2 1 𝑥𝑥3 1 𝑥𝑥4 𝑤𝑤0 𝑤𝑤1 = � 𝑦𝑦1 � 𝑦𝑦2 � 𝑦𝑦3 � 𝑦𝑦4 Minimize the objective function 1 4 ∑𝑖𝑖=1 4 � 𝑦𝑦𝑖𝑖 − 𝑦𝑦𝑖𝑖 2 or 1 4 ∑𝑖𝑖=1 4 � 𝑦𝑦𝑖𝑖 − 𝑦𝑦𝑖𝑖 2 + 𝜆𝜆 ∑𝑗𝑗=0 1 𝑤𝑤𝑗𝑗 2 Analytic solution & iterative solution
  • 24. COPYRIGHT 2017, THE UNIVERSITY OF MELBOURNE Multivariate linear regression (2-D points)  𝑥𝑥1,1, 𝑥𝑥1,2 → 𝑦𝑦1, 𝑥𝑥2,1, 𝑥𝑥2,2 → 𝑦𝑦2  𝑥𝑥3,1, 𝑥𝑥3,2 → 𝑦𝑦3, 𝑥𝑥4,1, 𝑥𝑥4,2 → 𝑦𝑦4  1 𝑥𝑥1,1 𝑥𝑥1,2 1 𝑥𝑥2,1 𝑥𝑥2,2 1 𝑥𝑥3,1 𝑥𝑥3,2 1 𝑥𝑥4,1 𝑥𝑥4,2 𝑤𝑤0 𝑤𝑤1 𝑤𝑤2 = � 𝑦𝑦1 � 𝑦𝑦2 � 𝑦𝑦3 � 𝑦𝑦4 Minimize the objective function 1 4 ∑𝑖𝑖=1 4 � 𝑦𝑦𝑖𝑖 − 𝑦𝑦𝑖𝑖 2 or 1 4 ∑𝑖𝑖=1 4 � 𝑦𝑦𝑖𝑖 − 𝑦𝑦𝑖𝑖 2 + 𝜆𝜆 ∑𝑗𝑗=0 2 𝑤𝑤𝑗𝑗 2 Analytic solution & iterative solution
  • 25. COPYRIGHT 2017, THE UNIVERSITY OF MELBOURNE Polynomial regression (Quadratic) 𝑥𝑥1 → 𝑦𝑦1, 𝑥𝑥2 → 𝑦𝑦2, 𝑥𝑥3 → 𝑦𝑦3, 𝑥𝑥4 → 𝑦𝑦4  1 𝑥𝑥1 𝑥𝑥1 2 1 𝑥𝑥2 𝑥𝑥2 2 1 𝑥𝑥3 𝑥𝑥3 2 1 𝑥𝑥4 𝑥𝑥4 2 𝑤𝑤0 𝑤𝑤1 𝑤𝑤2 = � 𝑦𝑦1 � 𝑦𝑦2 � 𝑦𝑦3 � 𝑦𝑦4 Minimize the objective function 1 4 ∑𝑖𝑖=1 4 � 𝑦𝑦𝑖𝑖 − 𝑦𝑦𝑖𝑖 2 or 1 4 ∑𝑖𝑖=1 4 � 𝑦𝑦𝑖𝑖 − 𝑦𝑦𝑖𝑖 2 + 𝜆𝜆 ∑𝑗𝑗=0 2 𝑤𝑤𝑗𝑗 2 Analytic solution & iterative solution