DeepOD icon indicating copy to clipboard operation
DeepOD copied to clipboard

All scores are zero except the last, which is a NaN

Open NAThompson opened this issue 7 months ago • 1 comments

To reproduce:

#!/usr/bin/env python3
import numpy
from deepod.models.time_series.dif import DeepIsolationForestTS

arr = numpy.empty(shape=(33, 741))
arr.fill(1.0)

# Also reproduces the issue:
# arr = numpy.random.rand(33, 741)

dif = DeepIsolationForestTS(device=None, seq_len=min(arr.shape[0], 100), max_samples=min(arr.shape[0], 256), hidden_dims=100)
dif.fit(arr)
scores = dif.decision_function(arr)
print(scores)

Output:

$VIRTUAL_ENV/lib/python3.9/site-packages/deepod/models/tabular/dif.py:256: RuntimeWarning: invalid value encountered in divide
  scores = 2 ** (-depth_sum / (len(clf.estimators_) * _average_path_length([clf.max_samples_])))
[00:00<00:00, 1088.64it/s]
[ 0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.
  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0. nan]

NAThompson avatar Nov 10 '23 19:11 NAThompson