Uploaded by Dwayne Campbell

BUILDModel

advertisement
CMU
FUNDAMENTALS OF MACHINE LEARNING
MACHINE LEARNING PROJECT – SIMPLE LINEAR REGRESSION
GOAL: Accurately predict the height of a person given his age
using the trained model.
1. BUILD THE MODEL AND TRAIN IT.
Using cleaned data obtained in assignment
t
A. BUILD THE MODEL (Simple Linear Regression Model)
THE MODEL:
𝒚 = ∝ +𝜷𝒙 + 𝜺 beta
̂ = ∝ +𝜷𝒙
THE PREDICTOR: 𝒚
i.
ii.
iii.
iv.
v.
vi.
vii.
Use a dictionary named parameters with alpha (∝) and beta (𝜷) as key, with values 40 and 4
respectively.
̂) which takes the parameters age and params.
Define a function y_hat (𝒚
Use the straight line equation ( y_hat = alpha + beta * age) to return (predict) height.
Pass the required parameters and run the function.
Does the height obtained match the given height?
Use a function named learn_parameters to find the correct alpha and beta.
Define a dummy dictionary named new_parameter which can have any value for alpha and
beta. Obtain the nearest values of alpha and beta. Replace the old values with new ones.
𝑏𝑒𝑡𝑎 =
𝑠𝑢𝑚 ((𝑥 − 𝑥𝑏𝑎𝑟 ) ∗ (𝑦 − 𝑦𝑏𝑎𝑟 ))
𝑠𝑢𝑚((𝑥 − 𝑥𝑏𝑎𝑟 ) ∗∗ 2
𝑎𝑙𝑝ℎ𝑎 = (𝑦 − 𝑦𝑏𝑎𝑟 ) − 𝑏𝑒𝑡𝑎 ∗ (𝑥 − 𝑥𝑏𝑎𝑟 )
Download