Building Your First Machine Learning Model from Scratch
In this lesson, we delve into the process of constructing a machine learning model using a toy example. We aim to understand the fundamentals of deep learning by exploring and developing simple models, starting with teaching a machine to identify vehicle types. Through step-by-step guidance, we cover representing samples, identifying features, assigning values to corresponding features, and establishing a Vector Space Model. Additionally, we discuss the importance of evaluating feature relevance in the model building process.
Uploaded on Nov 20, 2024 | 0 Views
Download Presentation
Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
E N D
Presentation Transcript
Lesson 2 My first machine learning model from Scratch [ For understanding Deep learning, one needs to know what we meant by building a machine learning model In this lesson, we take up a toy example, and try to build few simple models ] 1
Teach a machine to identify vehicle types Teach a machine to identify vehicle types 2
Represent the sample Represent the sample #Wheel Height Weight Color 4
Represent the sample Represent the sample #Wheel Height Weight Color Identify the features which can represent the objects ? = {?? ?? ?? ??} Height Weight Color } Feature set={ #Wheel 5
Represent the sample Represent the sample #Wheel Height Weight Color Identify the features which can represent the objects ? = {?? ?? ?? ??} For every sample, assign value to corresponding feature ??= {????????? ???} where ??? is the value assigned for the feature ?? 6
Represent the sample Represent the sample #Wheel Height Weight Color 4 6 500 Red 4 5.5 600 Blue 4 5 550 Yellow 2 3 200 Red 2 3.5 150 blue 2 4 250 Yellow For every object, assign value to corresponding feature ??= {????????? ???} where ??? is the value assigned for the feature ?? 7
Vector Space Model Vector Space Model #Wheel Height Weight Color Features Vectors 4 6 500 Red 4 5.5 600 Blue 4 5 550 Yellow 2 3 200 Red 2 3.5 150 blue 2 4 250 Yellow This form of representation is called Vector Space Model 8
Are all features useful? Are all features useful? Features #Wheel Height Weight Color Features Vectors 4 6 500 Red 4 5.5 600 Blue Good Features #Wheel Height Weight 4 5 550 Yellow 2 3 200 Red Bad Feature Colour 2 3.5 150 blue 2 4 250 Yellow 9
Let us consider single feature Let us consider single feature #Wheel Class Label Training Dataset Feature vector with Class label CAR 4 CAR 4 4 CAR BIKE 2 2 BIKE 2 BIKE 10
Given the #Wheel, identify the vehicle Given the #Wheel, identify the vehicle #Wheel Class Label CAR 4 CAR 4 4 CAR BIKE 2 2 BIKE 2 BIKE ? 2 11
Let us estimate Let us estimate #Wheel Class Label CAR 4 CAR 4 Pr(Vehicle type| #Wheel) = ? 4 CAR BIKE 2 2 BIKE 2 BIKE 12
Let us estimate the probability (type|#wheel) Let us estimate the probability (type|#wheel) #Wheel Class Label CAR 4 Pr(CAR| 4) = 100% Pr(BIKE| 4) = 0% CAR 4 4 CAR Pr(CAR| 2) = 0% Pr(BIKE| 2) = 100% BIKE 2 2 BIKE 2 BIKE 13
Ask the question now Ask the question now #Wheel Class Label CAR 4 Pr(CAR| 4) = 100% Pr(BIKE| 4) = 0% CAR 4 4 CAR Pr(CAR| 2) = 0% Pr(BIKE| 2) = 100% BIKE 2 2 BIKE ? {2} 2 BIKE Classifier 2 BIKE Pr(BIKE|2) > Pr(CAR|2) => BIKE 14
There are multiple ways There are multiple ways #Wheel Class Label CAR 4 CAR 4 4 CAR 1 5 3 BIKE 2 #Wheel BIKE CAR 2 BIKE 2 BIKE 15
There are multiple ways There are multiple ways #Wheel Class Label CAR 4 CAR 4 4 CAR 1 5 3 BIKE 2 #Wheel BIKE CAR 2 BIKE 2 BIKE Classifier 2 BIKE If #Wheel < 3, then it is BIKE 16
If selected feature is not sufficient If selected feature is not sufficient #Wheel Class Label CAR 4 Pr(CAR| 4) = 75% Pr(BIKE| 4) = 25% CAR 4 4 CAR Pr(CAR| 2) = 25% Pr(BIKE| 2) = 75% BIKE 2 2 BIKE ? 2 2 BIKE BIKE 4 2 CAR 17
If selected feature is not sufficient If selected feature is not sufficient #Wheel Class Label CAR 4 Pr(CAR| 4) = 75% Pr(BIKE| 4) = 25% CAR 4 4 CAR Pr(CAR| 2) = 25% Pr(BIKE| 2) = 75% BIKE 2 2 BIKE BIKE 2 2 BIKE BIKE 4 Pr(BIKE|2) > Pr(CAR|2) => BIKE 2 CAR 18
More Features More Features #Wheel Height Class Label H: High, height >= 5 CAR 4 H L: Low, height < 5 CAR 4 H 4 CAR H BIKE 2 L 2 BIKE L 2 BIKE L L BIKE 4 2 H CAR 19
Estimate the probabilities, and ask the same question Estimate the probabilities, and ask the same question #Wheel Height Class Label CAR 4 H Pr(CAR| 4,H) = 100% Pr(BIKE| 4,L) = 100% CAR 4 H Pr(CAR| 2,H) = 100% Pr(BIKE| 2,L) = 100% Pr(CAR| 4,L) = 0% Pr(BIKE|4,H) = 0% Pr(CAR| 2,L) = 0% Pr(BIKE| 2,H) = 0% 4 CAR H BIKE 2 L 2 BIKE L 2 BIKE L L BIKE 4 ? H} {2 2 H CAR 20
Estimate the probabilities, and ask the same question Estimate the probabilities, and ask the same question #Wheel Height Class Label CAR 4 H Pr(CAR| 4,H) = 100% Pr(BIKE| 4,L) = 100% CAR 4 H Pr(CAR| 2,H) = 100% Pr(BIKE| 2,L) = 100% Pr(CAR| 4,L) = 0% Pr(BIKE|4,H) = 0% Pr(CAR| 2,L) = 0% Pr(BIKE| 2,H) = 0% 4 CAR H BIKE 2 L 2 BIKE L 2 BIKE L L BIKE 4 CAR H} {2 2 H CAR 21
Multiple ways Multiple ways #Wheel Height Class Label Height CAR 4 H H CAR 4 H L 4 CAR H 3 5 #Wheel BIKE 2 L 2 BIKE L 2 BIKE L L BIKE 4 2 H CAR 22
Multiple ways Multiple ways #Wheel Height Class Label Height CAR 4 H H CAR 4 H L 4 CAR H 3 5 #Wheel BIKE 2 L #Wheel = 4? 2 BIKE L No Yes 2 BIKE L #Height = H? #Height = H? L BIKE Yes 4 Yes No No 2 H CAR 23
Summary Summary Identify the features Represent the vehicles by the features Remove non-informative features Build the classification model from the data Perform the classification task 24