Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- X=data[feature_set]
- vif = pd.DataFrame()
- vif['vif_factor'] = [variance_inflation_factor(X.values,i) for i in range(X.shape[1])]
- vif['features'] = X.columns
- vif.sort_values('vif_factor',axis=0,inplace=True, ascending=False)
- features_to_remove = vif.loc[vif['vif_factor'] > 10,'features'].values
- features_to_remove = list(features_to_remove)
- print(features_to_remove)
- vif_factor | feature
- 21 | age
- 9.7 | income
- 7 | gender ....and so on
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement