0% found this document useful (0 votes)
3 views63 pages

Machine Learning Part 1 - Regression

Uploaded by

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

Machine Learning Part 1 - Regression

Uploaded by

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

Ko Phyo is writing a book

1
Vocabulary

Regression
Classification
Loss Function
Continous
Discrete

2
Machine Learning Part 1

After completion this section, you will


understand the process of regression and
ml. You will be able to apply other
regression concepts with sklearn.

3
Types of Supervised Learning

အေမး။ ။ မနက်ြဖန်ရာသီဥတု
ဘယ်လို ရှ ိ မလဲ။

အေြဖ။ ။ ရာသီဥတုက ပူမယ်


(သို့ ) ေအးမယ်။

အေမး။ ။ မနက်ြဖန် ရာသီဥတု


ဘယ်လို ရှ ိ မလဲ။

အေြဖ။ ။ အပူချ ိန်က 84


Degree F ရှ ိ မယ်။
4
ML Life Cycle
1. Problem
Understanding
2. Data Understanding
3. Data Preprocessing
4. Modeling
5. Evaluation
6. Deployment

5
Regression: California Housing Price Prediction

https://colab.research.google.com/drive/1WPZgBe2x
AZD3MJVbvsvGntE07h4_dOFv?usp=sharing 6
7
2. Data Understanding

8
3. Data Preprocessing

9
10
Model တစ် ခု ေဆာက်ဖို့
ဘာေတွ လိလ ု ဲ?

11
4. Modeling

12
5. Evaluation

13
Housing Price Housing Price Value for MAE Value for MSE
True/ Original), y Predicted, ypred |y-ypred|

100 150

150 140

Housing Price Housing Price Value for MAE Value for MSE
True/ Original), y Predicted, ypred |y-ypred|

100 100

150 140

14
15
Cont’d

16
Cont’d

17
Contʼd

Absolute Error is also called L1 loss.


Square Error is also called L2 loss.

18
19
20
Simple Linear Regression

y = mx + b

21
Simple Linear Regression

y = b0+b1x

22
Multiple Linear Regression

y = b0 + b1 * x1 + b2 * x2 + …

23
Letʼs see how we evaluate our hypothesis
function (model) in regression!
For Regression
For Regression
For Regression

Loss = Actual - Predicted

We sum up all the losses and


divide by the number of data
points to get the average,
which is the estimate cost of
our model.
L1 Loss Function L2 Loss Function

Loss = Actual - Predicted

Mean Absolute Error MAE Mean Squared Error MSE


step 1, cost = 5.77 step 33, cost = 4.12

step 66, cost = 3.02 step 100, cost = 2.66


Letʼs see how a machine can learn how to
predict house prices during training.
Step 1
The machine gives answers based on a random model.

1. 2.
1. $120K
2. $130K
3. $210K 2 rooms, 25 m2 4 rooms, 34 m2
4. $202K

3. 4.

8 rooms, 45 m2 7 rooms, 40 m2
Step 1
The machine calculates the overall cost of the model.

1. 2.
1. $120K
2. $130K
3. $210K $320K $410K
4. $202K

3. 4.

$730K $698K
Step 1 Cost = 8.5
The machine calculates the overall cost of the model.

1. 2.

Cost = 8.5😥
$320K $410K

3. 4.

$730K $698K
Step 1 Cost = 8.5
The machine updates the previous model to minimize the cost.

1. 2.

$320K $410K

3. 4.

$730K $698K
Step 2
The machine gives answers based on the updated model.

1. 2.
1. $200K
2. $280K
3. $490K 2 rooms, 25 m2 4 rooms, 34 m2
4. $478K

3. 4.

8 rooms, 45 m2 7 rooms, 40 m2
Step 2
The machine calculates the overall cost of the model.

1. 2.
1. $200K
2. $280K
3. $490K $320K $410K
4. $478K

3. 4.

$730K $698K
Step 2 Cost = 4
The machine calculates the overall cost of the model.

1. 2.

Cost = 4🤔
$320K $410K

3. 4.

$730K $698K
Step 2 Cost = 4
The machine updates the previous model to minimize the cost.

1. 2.

$320K $410K

3. 4.

$730K $698K
Step 3
The machine gives answers based on the updated model.

1. 2.
1. $300K
2. $369K
3. $695K 2 rooms, 25 m2 4 rooms, 34 m2
4. $675K

3. 4.

8 rooms, 45 m2 7 rooms, 40 m2
Step 3
The machine calculates the overall cost of the model.

1. 2.
1. $300K
2. $369K
3. $695K $320K $410K
4. $675K

3. 4.

$730K $698K
Step 3 Cost = 1.6
The machine calculates the overall cost of the model.

1. 2.

Cost = 1.6😄
$320K $410K

3. 4.

$730K $698K
Now, the machine has reasonable intelligence to predict house
prices even if it is shown new data it has never seen before during
training.

$650K

6 rooms, 38 m2
How Machines Get the Most Optimal Model

1. Randomly guess a model.

2. Calculate each loss produced by the model using a loss


function (commonly use L2 loss function).

3. Calculate the overall cost of the model. (commonly use Mean


Squared Error)

4. Updates the previous model using a certain algorithm for


minimizing the loss.

5. Go to Step 2 again.
44
No Quiz, But Survey Form For this Month

https://forms.gle/efDdP2LFnkeGir7i9

45
Recall

46
Thank You

47
Linear Regression

https://colab.research.google.com/drive/1PLPSu12QRpNO7WFPjIhlNoy9tj37Oos2?usp=sh
aring (Please write code)

48
Simple Linear Regression

y = b0 + b1 * x

b1= sum( (xi-mean(x)) * (yi-mean(y))) / sum((xi – mean(x))^2)

b0 = mean(y) – b1 * mean(x)

49
Hey Let’s Take a Look

50
Cont’d

51
Godlilocks

52
Cont’d

53
Cont’d

54
55
Derivative of Mean Square Error (White Board)

56
Cont’d

57
Simple Linear Regression from Scratch

https://colab.research.google.com/drive/1rQmiJIhJLgNfQBUzhIYPfPEfR1-7A9lo?usp=shari
ng

58
Pre

https://colab.research.google.com/drive/1msrzlXVpyGhET-gHkuEaRjUn7toyDhPM?usp=sh
aring

59
Linear Regression from Scratch

https://colab.research.google.com/drive/1AsYjpUUdUtyYGKPKSs5i7Asrq-5AL0iY?usp=shar
ing

60
Regression

61
Which one is better?

62
Con’t

In machine learning, when are are teaching machines, we are finding rules by giving data and
labels..

63

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy