SlideShare a Scribd company logo
1 of 31
Download to read offline
Machine Learning using
Matlab
Lecture 2 Linear regression
Concerned questions
● Collaboration
○ The maximum number for a group is 3.
○ Submit technical report individually, include the whole framework of your project, and what you
have done in the project.
○ Your score will be given combining the whole project and your work.
● Project
○ A good technical report is composed of three parts: novel idea, good writing, and code (good
code ≠ high score)
○ Project flowchart (next slide)
● Submit your group list and project proposal (up to one page) by the end of this
week.
Flowchart of a ML project
Data collection and
annotation
Training data
(60%)
Validating data
(20%)
Test data
(20%)
Machine learning
model
Linear regression with one variable
Hypothesis:
Parameters:
Cost Function:
Goal: ?
Gradient descent
● Given a function fx , our objective is
● Repeat until convergence{
}
Concern
● If α is too small, gradient descent can be slow, more iterations are needed
● If α is too large, gradient descent can overshoot the minimum. It may fail to
converge, or even diverge.
● May converge to a local minimum if the cost function is non-convex
● When we approach a local minimum, gradient descent will automatically take
smaller steps. So, no need to decrease α over time.
● “Batch”: all the training examples are used in each step of gradient descent
Gradient descent for linear regression
(one variable)
Repeat until convergence{
}
Question: which algorithm is correct?
Repeat until convergence{
}
Repeat until convergence{
}
Correct
Gradient descent for linear regression
(one variable)
Repeat until convergence{
}
Linear regression with multiple variables
● n : number of features
● x(i) : input features of i-th training example
● x(j) : value of feature j in i-th training example
Area of site
(1000 square feet)
Size of living place
(1000 square feet)
Number of rooms Ages in years Selling price
3.472 0.998 7 42 25.9
3.531 1.500 7 62 29.5
2.275 1.175 6 40 27.9
4.050 1.232 6 54 25.9
... ... ... ... ...
Hypothesis
● Hypothesis for multiple features:
● If we define x0 = 1, then we have
Linear regression with multiple variables
Hypothesis:
Parameters:
Cost Function:
Gradient descent:
● Repeat until convergence{
}
Gradient descent for linear regression
(multiple variables)
Repeat{
}
Suggestions on gradient descent
● How to make sure gradient descent is working correctly?
● How to choose learning rate?
Make sure gradient descent is working correctly
● Ideal cost output: decrease sharply, then slightly decrease
● Declare convergence if cost decrease between two iterations is less than a
threshold
Choosing learning rate
● α too small, more iterations; α too large, may not converge
● To choose α, try
Ideal small large
Feature normalization - intuition
● Each feature has a different scale, which may generates an oval shape
● Result: more iterations to converge
● Solution: feature normalization
Feature normalization
● Feature scaling:
● Standard score:
Normal equation for linear regression
Area of site
(1000 square
feet)
Size of living
place (1000
square feet)
Number of
rooms
Ages in
years
Selling
price
3.472 0.998 7 42 25.9
3.531 1.500 7 62 29.5
2.275 1.175 6 40 27.9
4.050 1.232 6 54 25.9
Area of site
(1000 square
feet)
Size of living
place (1000
square feet)
Number of
rooms
Ages in
years
Selling
price
1 3.472 0.998 7 42 25.9
1 3.531 1.500 7 62 29.5
1 2.275 1.175 6 40 27.9
1 4.050 1.232 6 54 25.9
Normal equation for linear regression
● Instead of gradient descent, we can obtain the best solution using the
following equations:
● Matlab one line code: pinv(X’*X)*X’*y
Gradient descent vs normal equation
Gradient descent
● Need to choose learning rate
● Need many iterations
● Works well even when number of features
n is very large
Normal equation
● No learning rate
● No iterations
● Need to compute , slow when
is very large, non-invertible
Congratulations!
You have learnt your first ML model!
Questions?
Classification: logistic regression
Binary classification
● Examples:
○ Email: spam/not spam?
○ Tumor: malignant/benign?
○ Object: car/not car?
● ,where 1 is positive class, and 0 is negative class, e.g, spam (1) vs
not spam (0).
● Intuitively, negative class conveys absence of something
Hypothesis
● If hx > 0.5 , predict “y = 1”
● If hx < 0.5 , predict “y = 0”
●
Logistic regression model
● Hell
● sigmoid/logistic function:
Interpretation of hypothesis output
● Estimated probability that y = 1, given x , “parameterized” by T :
● Example: given tumor size, if we have , which means: tell patient
that 70% chance of tumor being malignant.
● As we only have two classes, we have:
Logistic regression
● when hx > 0.5 , predict “y = 1”
● when hx < 0.5 , predict “y = 0”
● Hx
● Decision boundary:
● Note: different ML model generates
different decision boundary
Decision boundary
Cost function
● A new representation of cost function:
● In linear regression, it is given by:
Cost function
● Logistic regression cost function:
● Intuition: if h(x) = 0, but y = 1, the learning algorithm will be penalized by a
very large cost.
● We can compact two cases into one equation:

More Related Content

What's hot

CHƯƠNG 1 ĐẠI SỐ MA TRẬN ỨNG DỤNG TRONG GIẢI TÍCH MẠNG
CHƯƠNG 1  ĐẠI SỐ MA TRẬN ỨNG DỤNG TRONG GIẢI  TÍCH MẠNGCHƯƠNG 1  ĐẠI SỐ MA TRẬN ỨNG DỤNG TRONG GIẢI  TÍCH MẠNG
CHƯƠNG 1 ĐẠI SỐ MA TRẬN ỨNG DỤNG TRONG GIẢI TÍCH MẠNGĐinh Công Thiện Taydo University
 
Dientuso Sld2
Dientuso Sld2Dientuso Sld2
Dientuso Sld2hoadktd
 
Neural Networks for Pattern Recognition
Neural Networks for Pattern RecognitionNeural Networks for Pattern Recognition
Neural Networks for Pattern RecognitionVipra Singh
 
Tài liệu thiết kế mạch in altium
Tài liệu thiết kế mạch in altiumTài liệu thiết kế mạch in altium
Tài liệu thiết kế mạch in altiumNgai Hoang Van
 
Biên soạn bộ đề thi trắc nghiệm môn điện tử cơ bản theo chương trình 150 tín ...
Biên soạn bộ đề thi trắc nghiệm môn điện tử cơ bản theo chương trình 150 tín ...Biên soạn bộ đề thi trắc nghiệm môn điện tử cơ bản theo chương trình 150 tín ...
Biên soạn bộ đề thi trắc nghiệm môn điện tử cơ bản theo chương trình 150 tín ...Man_Ebook
 
Global optimization
Global optimizationGlobal optimization
Global optimizationbpenalver
 
NGHIÊN CỨU THIẾT KẾ, CHẾ TẠO MÁY ĐO NỒNG ĐỘ CỒN DÙNG VI ĐIỀU KHIỂN
NGHIÊN CỨU THIẾT KẾ, CHẾ TẠO MÁY ĐO NỒNG ĐỘ CỒN DÙNG VI ĐIỀU KHIỂN NGHIÊN CỨU THIẾT KẾ, CHẾ TẠO MÁY ĐO NỒNG ĐỘ CỒN DÙNG VI ĐIỀU KHIỂN
NGHIÊN CỨU THIẾT KẾ, CHẾ TẠO MÁY ĐO NỒNG ĐỘ CỒN DÙNG VI ĐIỀU KHIỂN nataliej4
 
Lecture 2 (Machine Learning)
Lecture 2 (Machine Learning)Lecture 2 (Machine Learning)
Lecture 2 (Machine Learning)VARUN KUMAR
 
Nhận dạng mặt người bằng thuật toán PCA trên Matlab
Nhận dạng mặt người bằng thuật toán PCA trên MatlabNhận dạng mặt người bằng thuật toán PCA trên Matlab
Nhận dạng mặt người bằng thuật toán PCA trên Matlabhieu anh
 
Stable Diffusion path
Stable Diffusion pathStable Diffusion path
Stable Diffusion pathVitaly Bondar
 
2 matlab ly-thuyet_laptrinh_hamtoanhoc_
2 matlab ly-thuyet_laptrinh_hamtoanhoc_2 matlab ly-thuyet_laptrinh_hamtoanhoc_
2 matlab ly-thuyet_laptrinh_hamtoanhoc_Thân Văn Ngọc
 
Large-scale Video Classification with Convolutional Neural Network
Large-scale Video Classification with Convolutional Neural NetworkLarge-scale Video Classification with Convolutional Neural Network
Large-scale Video Classification with Convolutional Neural NetworkKhalidKhan412
 
Pp do thi va truc giao cap 2
Pp do thi va truc giao cap 2Pp do thi va truc giao cap 2
Pp do thi va truc giao cap 2nhóc Ngố
 
chuong 3. quan he
chuong 3. quan hechuong 3. quan he
chuong 3. quan hekikihoho
 
Giao trinh tu tuong ho chi minh
Giao trinh tu tuong ho chi minhGiao trinh tu tuong ho chi minh
Giao trinh tu tuong ho chi minhNguyen Van Hoa
 
Chương 1, tư tưởng hchinh
Chương 1, tư tưởng hchinhChương 1, tư tưởng hchinh
Chương 1, tư tưởng hchinhmai_mai_yb
 

What's hot (20)

CHƯƠNG 1 ĐẠI SỐ MA TRẬN ỨNG DỤNG TRONG GIẢI TÍCH MẠNG
CHƯƠNG 1  ĐẠI SỐ MA TRẬN ỨNG DỤNG TRONG GIẢI  TÍCH MẠNGCHƯƠNG 1  ĐẠI SỐ MA TRẬN ỨNG DỤNG TRONG GIẢI  TÍCH MẠNG
CHƯƠNG 1 ĐẠI SỐ MA TRẬN ỨNG DỤNG TRONG GIẢI TÍCH MẠNG
 
Dientuso Sld2
Dientuso Sld2Dientuso Sld2
Dientuso Sld2
 
Neural Networks for Pattern Recognition
Neural Networks for Pattern RecognitionNeural Networks for Pattern Recognition
Neural Networks for Pattern Recognition
 
Tài liệu thiết kế mạch in altium
Tài liệu thiết kế mạch in altiumTài liệu thiết kế mạch in altium
Tài liệu thiết kế mạch in altium
 
Biên soạn bộ đề thi trắc nghiệm môn điện tử cơ bản theo chương trình 150 tín ...
Biên soạn bộ đề thi trắc nghiệm môn điện tử cơ bản theo chương trình 150 tín ...Biên soạn bộ đề thi trắc nghiệm môn điện tử cơ bản theo chương trình 150 tín ...
Biên soạn bộ đề thi trắc nghiệm môn điện tử cơ bản theo chương trình 150 tín ...
 
Global optimization
Global optimizationGlobal optimization
Global optimization
 
NGHIÊN CỨU THIẾT KẾ, CHẾ TẠO MÁY ĐO NỒNG ĐỘ CỒN DÙNG VI ĐIỀU KHIỂN
NGHIÊN CỨU THIẾT KẾ, CHẾ TẠO MÁY ĐO NỒNG ĐỘ CỒN DÙNG VI ĐIỀU KHIỂN NGHIÊN CỨU THIẾT KẾ, CHẾ TẠO MÁY ĐO NỒNG ĐỘ CỒN DÙNG VI ĐIỀU KHIỂN
NGHIÊN CỨU THIẾT KẾ, CHẾ TẠO MÁY ĐO NỒNG ĐỘ CỒN DÙNG VI ĐIỀU KHIỂN
 
Lecture 2 (Machine Learning)
Lecture 2 (Machine Learning)Lecture 2 (Machine Learning)
Lecture 2 (Machine Learning)
 
Nhận dạng mặt người bằng thuật toán PCA trên Matlab
Nhận dạng mặt người bằng thuật toán PCA trên MatlabNhận dạng mặt người bằng thuật toán PCA trên Matlab
Nhận dạng mặt người bằng thuật toán PCA trên Matlab
 
Đề Thi HK2 Toán 8 - THCS Lê Quý Đôn
Đề Thi HK2 Toán 8 - THCS Lê Quý Đôn Đề Thi HK2 Toán 8 - THCS Lê Quý Đôn
Đề Thi HK2 Toán 8 - THCS Lê Quý Đôn
 
Stable Diffusion path
Stable Diffusion pathStable Diffusion path
Stable Diffusion path
 
Chuong02
Chuong02Chuong02
Chuong02
 
2 matlab ly-thuyet_laptrinh_hamtoanhoc_
2 matlab ly-thuyet_laptrinh_hamtoanhoc_2 matlab ly-thuyet_laptrinh_hamtoanhoc_
2 matlab ly-thuyet_laptrinh_hamtoanhoc_
 
Large-scale Video Classification with Convolutional Neural Network
Large-scale Video Classification with Convolutional Neural NetworkLarge-scale Video Classification with Convolutional Neural Network
Large-scale Video Classification with Convolutional Neural Network
 
Pp do thi va truc giao cap 2
Pp do thi va truc giao cap 2Pp do thi va truc giao cap 2
Pp do thi va truc giao cap 2
 
Luận văn: Ước lượng gradient cho phương trình khuếch tán phi tuyến
Luận văn: Ước lượng gradient cho phương trình khuếch tán phi tuyếnLuận văn: Ước lượng gradient cho phương trình khuếch tán phi tuyến
Luận văn: Ước lượng gradient cho phương trình khuếch tán phi tuyến
 
chuong 3. quan he
chuong 3. quan hechuong 3. quan he
chuong 3. quan he
 
Lắp ráp (Inventor)
Lắp ráp (Inventor)Lắp ráp (Inventor)
Lắp ráp (Inventor)
 
Giao trinh tu tuong ho chi minh
Giao trinh tu tuong ho chi minhGiao trinh tu tuong ho chi minh
Giao trinh tu tuong ho chi minh
 
Chương 1, tư tưởng hchinh
Chương 1, tư tưởng hchinhChương 1, tư tưởng hchinh
Chương 1, tư tưởng hchinh
 

Similar to Machine learning using matlab.pdf

Introduction to Machine Learning with Spark
Introduction to Machine Learning with SparkIntroduction to Machine Learning with Spark
Introduction to Machine Learning with Sparkdatamantra
 
Machine Learning and Deep Learning 4 dummies
Machine Learning and Deep Learning 4 dummies Machine Learning and Deep Learning 4 dummies
Machine Learning and Deep Learning 4 dummies Dori Waldman
 
Machine learning4dummies
Machine learning4dummiesMachine learning4dummies
Machine learning4dummiesMichael Winer
 
Dimensionality Reduction | Machine Learning | CloudxLab
Dimensionality Reduction | Machine Learning | CloudxLabDimensionality Reduction | Machine Learning | CloudxLab
Dimensionality Reduction | Machine Learning | CloudxLabCloudxLab
 
Artificial Intelligence Course: Linear models
Artificial Intelligence Course: Linear models Artificial Intelligence Course: Linear models
Artificial Intelligence Course: Linear models ananth
 
Lecture 3.1_ Logistic Regression.pptx
Lecture 3.1_ Logistic Regression.pptxLecture 3.1_ Logistic Regression.pptx
Lecture 3.1_ Logistic Regression.pptxajondaree
 
Deep Learning Module 2A Training MLP.pptx
Deep Learning Module 2A Training MLP.pptxDeep Learning Module 2A Training MLP.pptx
Deep Learning Module 2A Training MLP.pptxvipul6601
 
Overview on Optimization algorithms in Deep Learning
Overview on Optimization algorithms in Deep LearningOverview on Optimization algorithms in Deep Learning
Overview on Optimization algorithms in Deep LearningKhang Pham
 
Silicon valleycodecamp2013
Silicon valleycodecamp2013Silicon valleycodecamp2013
Silicon valleycodecamp2013Sanjeev Mishra
 
Dimensionality Reduction
Dimensionality ReductionDimensionality Reduction
Dimensionality ReductionSaad Elbeleidy
 
L1 intro2 supervised_learning
L1 intro2 supervised_learningL1 intro2 supervised_learning
L1 intro2 supervised_learningYogendra Singh
 
ngboost.pptx
ngboost.pptxngboost.pptx
ngboost.pptxHadrian7
 
Deep learning Unit1 BasicsAllllllll.pptx
Deep learning Unit1 BasicsAllllllll.pptxDeep learning Unit1 BasicsAllllllll.pptx
Deep learning Unit1 BasicsAllllllll.pptxFreefireGarena30
 
Strata 2016 - Lessons Learned from building real-life Machine Learning Systems
Strata 2016 -  Lessons Learned from building real-life Machine Learning SystemsStrata 2016 -  Lessons Learned from building real-life Machine Learning Systems
Strata 2016 - Lessons Learned from building real-life Machine Learning SystemsXavier Amatriain
 
Reinforcement Learning 6. Temporal Difference Learning
Reinforcement Learning 6. Temporal Difference LearningReinforcement Learning 6. Temporal Difference Learning
Reinforcement Learning 6. Temporal Difference LearningSeung Jae Lee
 

Similar to Machine learning using matlab.pdf (20)

Introduction to Machine Learning with Spark
Introduction to Machine Learning with SparkIntroduction to Machine Learning with Spark
Introduction to Machine Learning with Spark
 
Machine Learning and Deep Learning 4 dummies
Machine Learning and Deep Learning 4 dummies Machine Learning and Deep Learning 4 dummies
Machine Learning and Deep Learning 4 dummies
 
Machine learning4dummies
Machine learning4dummiesMachine learning4dummies
Machine learning4dummies
 
Dimensionality Reduction | Machine Learning | CloudxLab
Dimensionality Reduction | Machine Learning | CloudxLabDimensionality Reduction | Machine Learning | CloudxLab
Dimensionality Reduction | Machine Learning | CloudxLab
 
Artificial Intelligence Course: Linear models
Artificial Intelligence Course: Linear models Artificial Intelligence Course: Linear models
Artificial Intelligence Course: Linear models
 
Lecture 3.1_ Logistic Regression.pptx
Lecture 3.1_ Logistic Regression.pptxLecture 3.1_ Logistic Regression.pptx
Lecture 3.1_ Logistic Regression.pptx
 
Regression ppt
Regression pptRegression ppt
Regression ppt
 
SKLearn Workshop.pptx
SKLearn Workshop.pptxSKLearn Workshop.pptx
SKLearn Workshop.pptx
 
Deep Learning Module 2A Training MLP.pptx
Deep Learning Module 2A Training MLP.pptxDeep Learning Module 2A Training MLP.pptx
Deep Learning Module 2A Training MLP.pptx
 
Overview on Optimization algorithms in Deep Learning
Overview on Optimization algorithms in Deep LearningOverview on Optimization algorithms in Deep Learning
Overview on Optimization algorithms in Deep Learning
 
Silicon valleycodecamp2013
Silicon valleycodecamp2013Silicon valleycodecamp2013
Silicon valleycodecamp2013
 
Regression
RegressionRegression
Regression
 
Dimensionality Reduction
Dimensionality ReductionDimensionality Reduction
Dimensionality Reduction
 
L1 intro2 supervised_learning
L1 intro2 supervised_learningL1 intro2 supervised_learning
L1 intro2 supervised_learning
 
Svm V SVC
Svm V SVCSvm V SVC
Svm V SVC
 
ngboost.pptx
ngboost.pptxngboost.pptx
ngboost.pptx
 
Deep learning Unit1 BasicsAllllllll.pptx
Deep learning Unit1 BasicsAllllllll.pptxDeep learning Unit1 BasicsAllllllll.pptx
Deep learning Unit1 BasicsAllllllll.pptx
 
04 numerical
04 numerical04 numerical
04 numerical
 
Strata 2016 - Lessons Learned from building real-life Machine Learning Systems
Strata 2016 -  Lessons Learned from building real-life Machine Learning SystemsStrata 2016 -  Lessons Learned from building real-life Machine Learning Systems
Strata 2016 - Lessons Learned from building real-life Machine Learning Systems
 
Reinforcement Learning 6. Temporal Difference Learning
Reinforcement Learning 6. Temporal Difference LearningReinforcement Learning 6. Temporal Difference Learning
Reinforcement Learning 6. Temporal Difference Learning
 

Recently uploaded

Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZTE
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2RajaP95
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacingjaychoudhary37
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 

Recently uploaded (20)

Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacing
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 

Machine learning using matlab.pdf

  • 2. Concerned questions ● Collaboration ○ The maximum number for a group is 3. ○ Submit technical report individually, include the whole framework of your project, and what you have done in the project. ○ Your score will be given combining the whole project and your work. ● Project ○ A good technical report is composed of three parts: novel idea, good writing, and code (good code ≠ high score) ○ Project flowchart (next slide) ● Submit your group list and project proposal (up to one page) by the end of this week.
  • 3. Flowchart of a ML project Data collection and annotation Training data (60%) Validating data (20%) Test data (20%) Machine learning model
  • 4. Linear regression with one variable Hypothesis: Parameters: Cost Function: Goal: ?
  • 5. Gradient descent ● Given a function fx , our objective is ● Repeat until convergence{ }
  • 6. Concern ● If α is too small, gradient descent can be slow, more iterations are needed ● If α is too large, gradient descent can overshoot the minimum. It may fail to converge, or even diverge. ● May converge to a local minimum if the cost function is non-convex ● When we approach a local minimum, gradient descent will automatically take smaller steps. So, no need to decrease α over time. ● “Batch”: all the training examples are used in each step of gradient descent
  • 7. Gradient descent for linear regression (one variable) Repeat until convergence{ }
  • 8. Question: which algorithm is correct? Repeat until convergence{ } Repeat until convergence{ } Correct
  • 9. Gradient descent for linear regression (one variable) Repeat until convergence{ }
  • 10. Linear regression with multiple variables ● n : number of features ● x(i) : input features of i-th training example ● x(j) : value of feature j in i-th training example Area of site (1000 square feet) Size of living place (1000 square feet) Number of rooms Ages in years Selling price 3.472 0.998 7 42 25.9 3.531 1.500 7 62 29.5 2.275 1.175 6 40 27.9 4.050 1.232 6 54 25.9 ... ... ... ... ...
  • 11. Hypothesis ● Hypothesis for multiple features: ● If we define x0 = 1, then we have
  • 12. Linear regression with multiple variables Hypothesis: Parameters: Cost Function: Gradient descent: ● Repeat until convergence{ }
  • 13. Gradient descent for linear regression (multiple variables) Repeat{ }
  • 14. Suggestions on gradient descent ● How to make sure gradient descent is working correctly? ● How to choose learning rate?
  • 15. Make sure gradient descent is working correctly ● Ideal cost output: decrease sharply, then slightly decrease ● Declare convergence if cost decrease between two iterations is less than a threshold
  • 16. Choosing learning rate ● α too small, more iterations; α too large, may not converge ● To choose α, try Ideal small large
  • 17. Feature normalization - intuition ● Each feature has a different scale, which may generates an oval shape ● Result: more iterations to converge ● Solution: feature normalization
  • 18. Feature normalization ● Feature scaling: ● Standard score:
  • 19. Normal equation for linear regression Area of site (1000 square feet) Size of living place (1000 square feet) Number of rooms Ages in years Selling price 3.472 0.998 7 42 25.9 3.531 1.500 7 62 29.5 2.275 1.175 6 40 27.9 4.050 1.232 6 54 25.9 Area of site (1000 square feet) Size of living place (1000 square feet) Number of rooms Ages in years Selling price 1 3.472 0.998 7 42 25.9 1 3.531 1.500 7 62 29.5 1 2.275 1.175 6 40 27.9 1 4.050 1.232 6 54 25.9
  • 20. Normal equation for linear regression ● Instead of gradient descent, we can obtain the best solution using the following equations: ● Matlab one line code: pinv(X’*X)*X’*y
  • 21. Gradient descent vs normal equation Gradient descent ● Need to choose learning rate ● Need many iterations ● Works well even when number of features n is very large Normal equation ● No learning rate ● No iterations ● Need to compute , slow when is very large, non-invertible
  • 22. Congratulations! You have learnt your first ML model! Questions?
  • 24. Binary classification ● Examples: ○ Email: spam/not spam? ○ Tumor: malignant/benign? ○ Object: car/not car? ● ,where 1 is positive class, and 0 is negative class, e.g, spam (1) vs not spam (0). ● Intuitively, negative class conveys absence of something
  • 25. Hypothesis ● If hx > 0.5 , predict “y = 1” ● If hx < 0.5 , predict “y = 0” ●
  • 26. Logistic regression model ● Hell ● sigmoid/logistic function:
  • 27. Interpretation of hypothesis output ● Estimated probability that y = 1, given x , “parameterized” by T : ● Example: given tumor size, if we have , which means: tell patient that 70% chance of tumor being malignant. ● As we only have two classes, we have:
  • 28. Logistic regression ● when hx > 0.5 , predict “y = 1” ● when hx < 0.5 , predict “y = 0”
  • 29. ● Hx ● Decision boundary: ● Note: different ML model generates different decision boundary Decision boundary
  • 30. Cost function ● A new representation of cost function: ● In linear regression, it is given by:
  • 31. Cost function ● Logistic regression cost function: ● Intuition: if h(x) = 0, but y = 1, the learning algorithm will be penalized by a very large cost. ● We can compact two cases into one equation: