A fit method estimates a detector’s model from supplied training data. In PyOD, fit() prepares a detector such as KNN or KDE, after which training scores can be read from decision_scores_. section 6.1
A fitted PyOD detector supports several complementary operations:
- Use predict() for binary labels on separate test data. section 6.1
- Use decision_function() for numeric scores on separate test data. section 6.1
- Use labels_ and decision_scores_ to inspect labels and scores for the training rows. section 6.1
- Encode categorical features and fill None or NaN values before fitting numeric detectors. section 6.1
Fitting a KNN detector
from pyod.models.knn import KNN clf = KNN() clf.fit(data) scores = clf.decision_scores_

