我想用IsolationForest
来查找异常值。我想用GridSearchCV
找到模型的最佳参数。问题是我总是得到同样的错误:
TypeError: If no scoring is specified, the estimator passed should have a 'score' method. The estimator IsolationForest(behaviour='old', bootstrap=False, contamination='legacy',
max_features=1.0, max_samples='auto', n_estimators=100,
n_jobs=None, random_state=None, verbose=0, warm_start=False) does not.
这似乎是个问题,因为IsolationForest
没有{
您需要创建自己的评分函数,因为
^{pr2}$IsolationForest
没有内置score
方法。相反,您可以使用score_samples
中提供的score_samples
函数(可以看作是score
的代理)并创建自己的记分器,如here所述,并将其传递给GridSearchCV
。我修改了您的代码以执行以下操作:希望这有帮助!在
我相信评分是指GridSearchCV对象,而不是IsolationForest。在
如果它是“None”(默认值),它将尝试使用estimators评分,正如您所说的,它不存在。尝试在GridSearchCV对象中使用一个适合您的问题的available scoring metrics
相关问题 更多 >
编程相关推荐