pyod icon indicating copy to clipboard operation
pyod copied to clipboard

NaNs in ABOD and INNE

Open madarax64 opened this issue 2 years ago • 3 comments

Hello, Thanks for the brilliant work on PyOD. I am using the SUOD framework made from an ensemble of ODs (OCSVM, LOF and INNE). However, in some of my use cases, I get an error about NaNs or infinite values:

Traceback (most recent call last):
  File "ood_spp_pyod.py", line 172, in <module>
    clf.fit(x_train)
  File "C:\Users\madarax64\Anaconda3\envs\cv701\lib\site-packages\pyod\models\suod.py", line 222, in fit
    decision_score_mat, keep_scalar=True)
  File "C:\Users\madarax64\Anaconda3\envs\cv701\lib\site-packages\pyod\utils\utility.py", line 154, in standardizer
    X = check_array(X)
  File "C:\Users\madarax64\Anaconda3\envs\cv701\lib\site-packages\sklearn\utils\validation.py", line 800, in check_array
    _assert_all_finite(array, allow_nan=force_all_finite == "allow-nan")
  File "C:\Users\madarax64\Anaconda3\envs\cv701\lib\site-packages\sklearn\utils\validation.py", line 116, in _assert_all_finite
    type_err, msg_dtype if msg_dtype is not None else X.dtype
ValueError: Input contains NaN, infinity or a value too large for dtype('float64').

Digging deeper, I found out that the INNE OD produces NaN scores, which the decision score standardization in SUOD does not tolerate. Replacing the INNE with ABOD also has the same issue. Experiments with other ODs (e.g. OCSVM, LOF, IForest) seem to not be affected by this. I also tried to turn off random projection in the SUOD model (by setting rp_flag_global=False) but the issue persists. Ideally a simple solution would be to remove the ABOD/INNE detector from my ensemble, but they actually help alot and I'd like to keep them if possible. Could you please tell me how to resolve this?

madarax64 avatar Jun 28 '22 08:06 madarax64

Hi,

Thanks for your feedback. I have released a new version of INNE with some bugs fixed in PR https://github.com/yzhao062/pyod/pull/418 . Please try using it and don't hesitate to contact me if you have any questions about using INNE.

Thanks, Xin

xhan97 avatar Jun 29 '22 18:06 xhan97

Hello @xhan97 , Thanks for the response. In my tests so far, INNE now seems to be working perfectly, thank you. I'll keep testing, and if anything turns up, I'll let you know. Thank you again for the help. I really appreciate it!

madarax64 avatar Jun 30 '22 18:06 madarax64

For ABOD, looks like the NaN issue was also flagged in #10 as well...

madarax64 avatar Jun 30 '22 18:06 madarax64