1
$\begingroup$

Is there a way to test for multi-collinearity, like VIF for example, after fitting a model with LassoCV from Sklearn in Python? https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LassoCV.html

from sklearn.linear_model import LinearRegression
from sklearn.linear_model import LassoCV, RidgeCV

#start the model
la = LassoCV(cv = 5)

#fit
la.fit(Xtrain, ytrain)

#predict
yPred = la.predict(Xtest)
$\endgroup$
2
  • $\begingroup$ multicollinearity in what? Xtrain? fitting a model on Xtrain and then using a model to form a prediction vector based on Xtest doesn't change the collinearities that were in Xtrain or Xtest $\endgroup$ – develarist Aug 24 '20 at 11:53
  • $\begingroup$ yes I know. I only want to see if the model suffers from multicollinearity after fitting the training data. $\endgroup$ – endorphinus Aug 24 '20 at 12:05
1
$\begingroup$

multiply (get the dot-product of) Xtrain and the weights that the lasso model found to be optimal. This will give you a lasso model-weighted version of Xtrain that now weights the entire sample set of each individual feature column anywhere between 0-100%. Now run whichever multicollinearity tests as you normally would on the matrix such as its correlation matrix. The multicollinearity test will therefore exclude, or ignore, columns that the lasso model gave a weight of 0% to, for example, and will only consider all other features according to the weight that the model applied to them.

$\endgroup$
1
  • $\begingroup$ Great, thank you! $\endgroup$ – endorphinus Aug 24 '20 at 12:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.