yzhao062 / pyod

A Python Library for Outlier and Anomaly Detection, Integrating Classical and Deep Learning Techniques
http://pyod.readthedocs.io
BSD 2-Clause "Simplified" License
8.27k stars 1.35k forks source link

Issues with plotting the DecisionBoundaryDisplay #573

Open ETTAN93 opened 1 month ago

ETTAN93 commented 1 month ago

When using the sklearn's Isolation forest model, I can use the DecisionBoundaryDisplay function to plot for all 3 different response methods, e.g. 'predict' and 'decision_function', without any issues. Example is given here.

This is how I initialize the models.

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,
    )

However, if I use the IForest from PYOD and try to do the same, I get the error below

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

image

Is a different object returned entirely from IForest compared to sklearn's version? How would I plot the same plot in PYOD?