I am trying to get a rough overlook on good parameters for several models including LogisticRegression with RandomizedSearchCV. Since some of the parameters combinations are incompatible I get sklearn FitFailedWarning i.e Solver newton-cg supports only 'l2' or 'none' penalties, got l1 penalty.
I would like to simply ignore those specific warnings and the solution I found to do so was to use :
from sklearn.exceptions import FitFailedWarning
from sklearn.utils._testing import ignore_warnings
with ignore_warnings(category=[FitFailedWarning]):
grid.fit(x_train, y_train)
My problem is that, although that works normally for most grids models (knn, decision tree etc.) it fails for LogisticRegression grid with error:
TypeError: issubclass() arg 2 must be a class or tuple of classes
while following fit without ignore_warnings works
lr_grid.fit(x_train, y_train)
Is there another proper way to silence FitFailedWarning for RandomizedSearchCV with LogisticRegression?