假设我们正在尝试找到 的最佳max_depth
参数RandomForestClassifier
。我们正在使用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 样本......”?
当我现在运行此代码时,我会收到此错误: