text_plain_output_1.png
from sklearn.datasets import load_boston

import matplotlib.pyplot as plt

import pandas as pd

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

import seaborn as sns

import statsmodels.formula.api as smf

from sklearn.datasets import load_boston
data = load_boston()

df = pd.DataFrame(data.data, columns=data.feature_names)

df['MEDV'] = data.target

plt.figure(figsize = (20, 15))
plotnumber = 1

for column in df:
    if plotnumber <= 14:
        ax = plt.subplot(3, 5, plotnumber)
        sns.distplot(df[column])
        plt.xlabel(column, fontsize = 15)
        
    plotnumber += 1
    
plt.tight_layout()
plt.show()

plt.figure(figsize = (20, 15))
plotnumber = 1

for column in df:
    if plotnumber <= 14:
        ax = plt.subplot(3, 5, plotnumber)
        sns.scatterplot(x = df['MEDV'], y = df[column])
        
    plotnumber += 1

plt.tight_layout()
plt.show()

X = df.drop(columns='MEDV', axis=1)
y = df['MEDV']

# Heatmap

fig, ax = plt.subplots(figsize = (16, 8))
sns.heatmap(df.corr(), annot = True, fmt = '1.2f', annot_kws = {'size' : 10}, linewidth = 1)
plt.show()

import statsmodels.formula.api as smf
lm = smf.ols(formula='MEDV ~ RAD', data=df).fit()
lm.summary()

lm = smf.ols(formula='MEDV ~ TAX', data=df).fit()
lm.summary()