我正在尝试拟合随机森林模型。如果我不使用条件参数,则代码会编译。但是,使用它会返回以下错误。
条件= 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)
有人可以帮忙吗?
最佳答案
您正在使用RandomForestRegressor
,这就是为什么它仅接受mae和mse的原因。
相反,请使用RandomForestClassifier
:
from sklearn.ensemble import RandomForestClassifier
clf = RandomForestClassifier(n_estimators=100,criterion="entropy",max_features='log2',bootstrap=False,random_state=1)
关于compiler-errors - 将参数传递给RandomForest时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60696849/