Skip to content
ML Academy

Classical ML, validation, metrics, interpretation, debugging · insight-1185

Choose outlier or novelty mode from whether the training data may already contain anomalies

Evidence type
documented fact
Difficulty
medium
Roles
Data scientist, ML engineer
Industries
manufacturing, banking, aviation

Summary: situation, action, reason, boundary

  1. Situation

    A local outlier factor model is fitted on historical records and then asked to score new records, or its predictions on the training rows are used to evaluate it.

  2. Action

    Decide by the data. If history is screened and mostly clean, use novelty mode and score only unseen rows, evaluated on a later period. If history is unscreened, use outlier mode to flag the training rows, review them, and refit on the cleaned set.

  3. Reason

    The two modes answer different questions: which training points are deviant, versus whether a new point is unlike clean training data.

  4. Boundary

    Local outlier factor and other detectors with outlier and novelty variants.

Symptom or risk

In the default outlier mode only fit_predict is offered; with novelty=True, predict or score_samples on training rows gives wrong results. Either way, a contaminated history can mask the anomalies you want.

Exceptions

Detectors with one interface, where the choice shows up only in how you split data.

Trade-offs

Cleaning history costs reviewer time and can remove rare but legitimate events.

Pitfalls

Calling predict on the training set in novelty mode and reporting its agreement with fit_predict.

Lessons and concepts

Claims and their sources

  • scikit-learn separates outlier detection (training data may contain outliers) from novelty detection (training data clean, scoring new observations); with novelty=True LocalOutlierFactor should not call predict, decision_function or score_samples on training samples.

    Novelty and Outlier Detection (scikit-learn User Guide 2.7)