In [ ]:
bmi_life_data = pd.read_csv('bmi_and_life_expectancy.csv')
In [ ]:
def linear_regression(x, y):
m=1
b=0
for epoch in range(epochs):
for i in range(len(x)):
pred = m*x[i] + b
diff = y[i] - pred
m += m*diff*learning_rate
b += diff*learning_rate
return m, b
In [ ]:
def predict(m, b, bmi):
return m[0]*bmi + b[0]
m, b = linear_regression(x, y)
predict(m, b, 21.07931)
In [ ]: