liveBook · Manning

Fit method

As explained in Outlier Detection in Python

A model-fitting method that estimates a model’s parameters or structure from supplied data.

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_

How Outlier Detection in Python covers it

How deep it goes
Explains fitting outputs and preprocessing requirements, but defers the internal training procedures of individual detectors.
Examples
Uses PyOD KNN and KDE detectors, synthetic clustered data, training scores, test scores, labels, and score visualizations.
What it assumes
Requires prepared numeric data, including encoded categorical features and filled None or NaN values.
What you can do after
Apply PyOD fit() to train a detector and retrieve training or test-data outlier results.
How it connects
Connects model fitting with training data, prediction, decision functions, outlier scores, KNN, and KDE.

Also explained in

Compare how 2 books explain fit method →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Outlier Detection in Python. The section links point to the parts of the book it draws on.