Skip to content

Multicollinearity: Variance Inflation Factor in Python Videos

Last Update: March 22, 2022

My online video tutorials are hosted at YouTube channel.

For learning this concept, you can view my online video tutorials: Multicollinearity: Variance Inflation Factor in Python (Spyder) and Multicollinearity: Variance Inflation Factor in Python (Jupyter).

Videos Code

1. Packages

import numpy as np
import pandas as pd
import seaborn as sns
import statsmodels.api as sm

2. Data

houseprices_object = sm.datasets.get_rdataset(dataname="HousePrices",
                                              package="AER", cache=True)
houseprices = houseprices_object.data
print(houseprices.iloc[:, 0:5].head())
print(houseprices_object.__doc__)

3. Variables

ivar = houseprices.iloc[:, 1:5]
print(ivar.head())

4. Multicollinearity

ivaricor = np.linalg.inv(ivar.corr())
ivaricor = pd.DataFrame(data=ivaricor, index=ivar.columns,
                        columns=ivar.columns)
print(ivaricor)
sns.heatmap(data=ivaricor, cmap="Blues", annot=True)

Courses

My online courses are hosted at Teachable website.

For more details on this concept, you can view my Linear Regression in Python Course.

My online courses are closed for enrollment.
+