首页 > 解决方案 > 关于 scikit-learn 的 IsolationForest 异常分数计算变化的问题?

问题描述

在sklearn的当前版本(v0.24)中,异常分数由函数计算_compute_score_samples点击这里

def _compute_score_samples(self, X, subsample_features):
    scores = 2 ** (
        -depths
        / (len(self.estimators_)
           * _average_path_length([self.max_samples_]))
    )
    return scores

但是,在 v0.19 中,单击此处此计算有所不同:

# https://github.com/scikit-learn/scikit-learn/blob/a24c8b46/sklearn/ensemble/iforest.py
scores = 2 ** (-depths.mean(axis=1) / _average_path_length(self.max_samples_))

现在,问题是:为什么 sklearn v0.24 计算depths/len(self.estimators_),而不是depths.mean(axis=1)v0.19?

标签: pythonscikit-learn

解决方案


推荐阅读