How to suppress "Estimator fit failed. The score on this train-test" warning message?

I am working on hyper-tuning random forest classifier with following parameters in random search CV

In [100]: # defining model

Model = RandomForestClassifier(random state=1)

# Parameter grid to pass in RandomSearchCV

param grid =
{ n_estimators: [200,250,300], min_samples_leaf: np.arange(1, 4), max_features: [np.arange(0.3, 0.6, 0.1),'sqrt'],max_samples: np.arange(0.4, 0.7, 0.1)}

#Calling RandomizedSearchcV

randomized_cv = RandomizedSearchCV(estimator=Model, param     distributions=param grid, n_iter=10, n_jobs = -1, scoring=metrics.make_scorer(metrics.recall_score))

#Fitting parameters in RandomizedSearchcv

randomized cv.fit(X train, y train)
print (Best parameters are {} with CV score={}: .format (randomized_cv.best params_,randomized_cv.best_score_))


 File /Users/thiyaga/opt/anaconda3/lib/python3.9/site- packages/joblib/parallel.py, line 262, in
 call
 return [func(*args, **kwargs)
 File /Users/thiyaga/opt/anaconda3/lib/python3.9/site-   packages/joblib/parallel.py, line 262, in listcomp
 return [func(*args, **kwargs)
 File /Users/thiyaga/opt/anaconda3/lib/python3.9/site- packages/sklearn/utils/fixes.py, line 222, in
 call
 return self. function(*args, **kwargs)
 File /Users/thiyaga/opt/anaconda3/lib/python3.9/site- packages/sklearn/ensemble/_forest.py, line 169, in parall
 el build trees
 tree.fit(X, y, sample weight=curr sample weight, check input=False)
 File /Users/thiyaga/opt/anaconda3/lib/python3.9/site-packages/sklearn/tree/classes.py,line 903, in fit
 super@).fitl
 File /Users/thiyaga/opt/anaconda3/lib/python3.9/site-packages/sklearn/tree/_classes.py,line 273, in fit
if self.max features  0.0:
ValueError: The truth value of an arrav with more than one  element is ambiguous. Use a.an() or a.all()
warnings.warn (Estimator fit failed. The score on this train-test

output is

Best parameters are

 {'n estimators': 250,
 'min samples leaf': 1,
 'max samples': 0.6,
 'max features':'sqrt'}
 

with CV score=0.6996248466921577; along with this warning message. To avoid warning message imported

import warnings
warnings.filterwarnings(ignore)
from sklearn.exceptions import FitFailedWarning 

still warning message appears.

Topic hyperparameter-tuning machine-learning-model hyperparameter random-forest machine-learning

Category Data Science

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.