I am esing the ElasticNet
from sklearn
.
With the typical commands
enet = ElasticNet(alpha=a, l1_ratio=l, random_state=42, tol=1e-8)
enet.fit(X_train, y_train)
sometimes the model does not converge, i.e. I get the following
ConvergenceWarning: Objective did not converge. You might want to increase the number of iterations, check the scale of the features or consider increasing regularisation. Duality gap: 3.378e+00, tolerance: 7.066e-08 Linear regression models with null weight for the l1 regularization term are more efficiently fitted using one of the solvers implemented in sklearn.linear_model.Ridge/RidgeCV instead.
model = cd_fast.enet_coordinate_descent(
I know this is not a good sign and I would like to handle such cases on my own. I would like to prompt a certain action if the model generates this warning. For example
if warning "non convegence": display something
Somebody can help? Unfortunately I cannot find how to retrieve this type of error so that I can handle it manually