In [1]:
import pandas as pd
from sklearn.linear_model import LinearRegression
In [10]:
# https://github.com/scipy/scipy/issues/5998
import warnings
warnings.filterwarnings(action="ignore", module="scipy", message="^internal gelsd")
In [11]:
model = LinearRegression()
In [12]:
bmi_life_data = pd.read_csv("bmi_and_life_expectancy.csv")
model.fit(bmi_life_data[['BMI']], bmi_life_data[['Life expectancy']])
Out[12]:
In [13]:
laos_life_exp = model.predict(21.07931)
In [14]:
print(laos_life_exp)
In [15]:
from sklearn.datasets import load_boston
In [16]:
boston_data = load_boston()
x = boston_data['data']
y = boston_data['target']
In [17]:
house_model = LinearRegression()
house_model.fit(x, y)
Out[17]:
In [18]:
sample_house = [[2.29690000e-01, 0.00000000e+00, 1.05900000e+01, 0.00000000e+00, 4.89000000e-01,
6.32600000e+00, 5.25000000e+01, 4.35490000e+00, 4.00000000e+00, 2.77000000e+02,
1.86000000e+01, 3.94870000e+02, 1.09700000e+01]]
# TODO: Predict housing price for the sample_house
prediction = house_model.predict(sample_house)
In [19]:
print(prediction)