I am trying to search for a best parameter combination for my model (RandomForestRegressor) using RandomizedSearchCV. But I am facing a challenge. RandomizedSearchCV seems to be taking eternity before it runs and bring an output. It has been running for a very long time now without any output.
This is the code:
From sklearn.preprocesing import MinMaxScaler` `X=df.iloc[:,:-1]` `scaler= MinMaxScaler()` `X_scaled=scaler.fit_transform(X)` `X=pd.DataFrame(X_scaled, columns=X.columns, index= X.index)` `y=df.iloc[:,-1:]your text
`
from sklearn.model_selection import train_test_split` `from sklearn.ensemble import RandomForestRegressor` `from sklearn.model_selection import GridSearchCV, RandomizedSearchCV `from sklearn.metrics import r2_score
`
“param_d={“max_depth”:[2,3], “n_estimators”:[100,400],”min_samples_split”:[2,4],”max_features”:[“sqrt”, “None”],”criterion”:[“squared_error”, “absolute_error”] }
Rdfr=RandomForestRegressor(max_samples=0.7, oob_score=True)
Randomsearch=RandomizedSearchCV(Rdfr,param_distributions=param_d,n_iter=10,scoring=”r2″, cv=4, n_jobs=-1)
Randomsearch.fit(X,y)
randomsearch.cv_result_
df_result=pd.DataFrame(Randomsearch.cv_result_)
df_result
I am also experiencing the same thing with GridSearchCV. But for GridSearchCV it is naturally very slow that is i am not bothered. so I decide to switch to RandomiseSearchCV and I am experiecing the same thing
please I need help.