image_output_1.png
from sklearn.datasets import load_boston

from sklearn.preprocessing import StandardScaler

from statsmodels.stats.outliers_influence import variance_inflation_factor

import pandas as pd

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

from sklearn.datasets import load_boston
data = load_boston()

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

df['MEDV'] = data.target

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

from sklearn.preprocessing import StandardScaler
scaler = StandardScaler()
X_scaled = scaler.fit_transform(X)

from statsmodels.stats.outliers_influence import variance_inflation_factor
vif = pd.DataFrame()
vif['VIF'] = [variance_inflation_factor(X_scaled, i) for i in range(X_scaled.shape[1])]
vif['Features'] = X.columns
vif

X.drop(columns=['TAX'], axis=1)