ISLP Package

Install ISLP Package

in a terminal: pip install ISLP

from ISLP import load_data
from ISLP.models import (ModelSpec as MS,
                         summarize,
                         poly)

Using Transformations: Fit and Transform

design = MS(['column'])
design = design.fit(dataframe)
X = design.transform(dataframe)

-or-

design = MS(['column'])
X = design.fit_transform(dataframe)
predictions = results.get_prediction(newXArray)
predictions.conf_int(alpha=0.05) #conf intervals
predictions.conf_int(obs=True, alpha=0.05) #pred intervals

Multivariate Goodness of Fit

List Comprehension

use a list comprehension to generate VIF for a list of variables X in the model matrix:

vals = [VIF(X, i)
        for i in range(1, X.shape[1])]
vif = pd.DataFrame({'vif':vals},
                   index=X.columns[1:])

could also construct vals with a different for loop:

vals = []
for i in range(1, X.values.shape[1]):
    vals.append(VIF(X.values, i))

Connect With Me!