将参数传递给RandomForest时出错

时间:2020-03-15 19:36:59

标签: compiler-errors random-forest

我正在尝试拟合随机森林模型。如果我不使用 criterion 参数,则会编译代码。但是,使用它会返回以下错误。

条件= CRITERIA_REG [self.criterion](self.n_outputs_, KeyError:“熵”

我的尝试是这样:

from sklearn.ensemble import RandomForestRegressor
clf = RandomForestRegressor(n_estimators=100,criterion="entropy",max_features='log2',bootstrap=False,random_state=1)

有人可以帮忙吗?

1 个答案:

答案 0 :(得分:0)

您正在使用RandomForestRegressor,这就是为什么它仅接受 mae mse 的原因。 而是使用RandomForestClassifier

from sklearn.ensemble import RandomForestClassifier
clf = RandomForestClassifier(n_estimators=100,criterion="entropy",max_features='log2',bootstrap=False,random_state=1)
相关问题