text_plain_output_1.png
import pandas as pd

import seaborn as sns

import statsmodels.api as sm

df = pd.read_csv('../input/random-linear-regression/train.csv')

df.shape

df.corr()

x_train.shape

x_train_sm = sm.add_constant(x_train)
x_train_sm

model = sm.OLS(y_train, x_train_sm)
lr_model = model.fit()

lr_model.params

lr_model.summary()

y_train_pred = lr_model.predict(x_train_sm)

res = y_train - y_train_pred

sns.distplot(res)