import numpy as np
import pandas as pd

import matplotlib.pyplot as plt
import seaborn as sns
from sklearn import linear_model
from sklearn.metrics import mean_squared_error,r2_score
url1 = "https://ilovedata.github.io/teaching/bigdata2/data/father-and-son.csv"
father_son_df = pd.read_csv(url1)

father_son_df.fheight =  father_son_df.fheight*2.54
father_son_df.sheight =  father_son_df.sheight*2.54
x = np.array(father_son_df["fheight"]).reshape(-1,1)
y = np.array(father_son_df["sheight"])

model = linear_model.LinearRegression()
model.fit(x,y)
pred = model.predict(x)
print(model.intercept_,model.coef_)
86.07197505935792 [0.51409304]
print("평균제곱오차, mse: %.2f" % mean_squared_error(y, y_pred))
평균제곱오차, mse: 38.23
print("결정계수 R^2: %.2f" % r2_score(y, y_pred))
결정계수 R^2: 0.25