将参数传递到RandomForest时出错



我正在尝试拟合一个随机林模型。如果我不使用标准参数,代码就会编译。然而,它在使用时返回以下错误。

CRITERIA=标准_ REG〔self.CRITERIA〕(self.noutputs_,KeyError:"熵">

我的尝试是:

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

有人能帮忙吗?

您使用的是RandomForestRegressor,这就是为什么它只接受maemse
请使用RandomForestClassifier:

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

最新更新