OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

RandomizedSearchCV is taking very long long time to run

  • Thread starter Thread starter David
  • Start date Start date
D

David

Guest
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:

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:]

Code:
 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

Code:
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 so I am not bothered. so I decide to switch to RandomizedSearchCV and I am experiencing the same thing .

please I need help.
<p>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.</p>
<p>This is the code:</p>
<pre><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:]
</code></pre>
<pre><code> 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
</code></pre>
<pre><code>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)
</code></pre>
<p>Randomsearch.fit(X,y)
randomsearch.cv_result_
df_result=pd.DataFrame(Randomsearch.cv_result_)
df_result</p>
<p>I am also experiencing the same thing with GridSearchCV.
But for GridSearchCV it is naturally very slow
so I am not bothered. so I decide to switch to RandomizedSearchCV and I am experiencing the same thing .</p>
<p>please I need help.</p>
 

Latest posts

Top