1
比方說,我們正試圖找到RandomForestClassifier
的最佳參數max_depth
。我們使用RandomizedSearchCV
:如何判斷RandomizedSearchCV從發佈或無值中進行選擇?
from scipy.stats import randint as sp_randint
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import RandomizedSearchCV
rf_params = { # Is this somehow possible?
'max_depth': [sp_randint(1, 100), None],
}
n_iter = 10
random_search = RandomizedSearchCV(RandomForestClassifier(),
verbose=50,
param_distributions=rf_params,
n_iter=n_iter,
n_jobs=-1,
scoring='f1_micro')
random_search.fit(X_train, y_train)
是否可以告訴RandomizedSearchCV
無論是從指定的分發sp_randint(1, 100)
或者設置參數選擇None
將(如文檔):」 ......擴大是節點,直到所有的葉子純粹或直到所有葉子都包含小於min_samples_split樣本......「?
當我現在運行此代碼,我會得到這個錯誤:
謝謝你的回答,但現在真的有很小的機會從這樣的列表中隨機選擇'None',這可以以某種方式改進嗎? – delusionX
什麼是「改進」給你?我問,因爲如果你想保證它被選中,你最好用GridSearchCV。 –
也許一些不同的分佈比統一,讓我們說幾何(https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.geom.html#scipy.stats.geom)哪裏沒有高概率P(x =無)。 – delusionX