from statsmodels.stats.outliers_influence import variance_inflation_factor 
# creating dummies for gender 
data['Gender'] = data['Gender'].map({'Male':0, 'Female':1}) 
# the independent variables set 
X = data[['Gender', 'Height', 'Weight']] 
# VIF dataframe 
vif_data = pd.DataFrame() 
vif_data["feature"] = X.columns 
# calculating VIF for each feature 
vif_data["VIF"] = [variance_inflation_factor(X.values, i) 
                          for i in range(len(X.columns))] 
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter