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