image_output_1.png
from statsmodels.stats.outliers_influence import variance_inflation_factor

import pandas as pd

import seaborn as sns

df = pd.read_csv('../input/car-price-prediction/CarPrice_Assignment.csv')

df.describe(include='all').style.background_gradient(cmap='Blues').set_properties(**{'font-family': 'Segoe UI'})

df_c = df.copy()

df_c = df_c.drop_duplicates()

df_c = pd.get_dummies(df_c, columns=['fueltype', 'aspiration', 'carbody', 'drivewheel', 'enginelocation', 'enginetype', 'fuelsystem'])

df_c = pd.get_dummies(df_c, columns=['CarName'])

from statsmodels.stats.outliers_influence import variance_inflation_factor
vif_df = df_c.loc[:, df_c.columns != 'price']
vif_data = pd.DataFrame()
vif_data['feature'] = vif_df.columns
vif_data['VIF'] = [variance_inflation_factor(vif_df.values, i) for i in range(len(vif_df.columns))]
vif_data.head(17)