text_plain_output_1.png
from sklearn import datasets

from sklearn.model_selection import train_test_split

import matplotlib.pyplot as plt

import pandas as pd

import seaborn as sns

import statsmodels.api as sm

boston = datasets.load_boston()

bos = pd.DataFrame(boston.data, columns=boston.feature_names)
target = pd.DataFrame(boston.target, columns=['MEDV'])
bos['MEDV'] = target['MEDV']

correlation_matrix = bos.corr().round(2)

X = bos[['RM', 'LSTAT']]
Y = target['MEDV']
model = sm.OLS(Y, X).fit()
predictions = model.predict(X)
model.summary()

X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size=0.33, random_state=5)
print(X_train.shape)
print(X_test.shape)
print(Y_train.shape)
print(Y_test.shape)