#573·pyod

绘制 DecisionBoundaryDisplay 存在问题

作者: ETTAN93创建于 2024年5月14日更新于 2026年9月18日

在使用 sklearn 的 孤立森林模型 时,我可以使用 DecisionBoundaryDisplay 函数来绘制所有 3 种不同的响应方法,例如 'predict' 和 'decision_function',没有任何问题。示例可在 这里 查看。以下是我初始化模型的代码片段:

python
from sklearn.ensemble import IsolationForest
iforest_model = IsolationForest(
    n_estimators=100,
    contamination=0.005,
    random_state=24,
)
iforest_model.fit(x_train)
disp = DecisionBoundaryDisplay.from_estimator(
        estimator=iforest_model,
        X=x_df_to_plot,
        response_method='decision_function',
        alpha=0.5,
    )

然而,如果我使用 PYOD 中的 IForest 并尝试执行相同的操作,则会出现以下错误:

python
from pyod.models.iforest import IForest
iforest_model = IForest(
    n_estimators=100,
    contamination=0.005,
    random_state=24,
)

image IForest 返回的对象与 sklearn 版本完全不同吗?我如何在 PYOD 中绘制相同的图像?