yzhao062 / pytod

TOD: GPU-accelerated Outlier Detection via Tensor Operations
https://arxiv.org/abs/2110.14007
BSD 2-Clause "Simplified" License
173 stars 24 forks source link

decision_function() returns None #6

Open sugatc opened 1 year ago

sugatc commented 1 year ago

Thanks for the package. When I try to implement LOF (or KNN) decision_function() on test data returns empty object. Is there a fix to this? Following is the code that replicates the issue (on GPU):

from pytod.models.lof import LOF import torch import numpy as np

x = np.array([[1, 2], [3, 4], [5, 6], [7, 8], [75,80]], dtype=np.float32) x = torch.from_numpy(x)

y = np.array([[6, 5], [1, 2], [3, 4], [5, 1], [11,12]], dtype=np.float32) y = torch.from_numpy(y)

lof = LOF(n_neighbors=2, device = 'cuda:0')

lof.fit(x)

print(lof.decision_function(y))