Novelty versus outliers
Quick answer
An anomaly detector flags observations that differ from a reference pattern. Novelty detection learns from a reference believed to be normal and scores new observations. Outlier detection instead seeks unusual observations in a possibly contaminated sample. Neither establishes why an observation is unusual. Examples are static Python snippets tested locally on CPU; Native detector examples require NumPy and scikit-learn; exercises use standard-library Python. ByteMind execution is unverified.
Explicit threshold boundary
scores=[1,4,2,4]print([int(s>=4) for s in scores])Expected output (locally tested): [0, 1, 0, 1]. The inclusive threshold flags both tied scores.
How it works
Consider a temperature sensor whose expected reading depends on operating mode. A value of 30 might be routine in hot mode but unusual in cold mode. A detector based on a single global threshold would ignore that context. Define the reference population, feature availability and unit of review before scoring. Outlier detection can fit a contaminated training set; novelty detection assumes a representative normal reference, not perfect labels. In scikit-learn many detectors use predict labels +1 for inlier and -1 for outlier, and decision_function values below zero for outliers. A score is a ranking or decision statistic, not a calibrated anomaly probability. For a custom score where larger means more unusual, explicitly define an inclusive or exclusive threshold. False alarm rate is FP/(FP+TN), measured among actual normal observations; detection recall is TP/(TP+FN). If a denominator is zero, report undefined rather than inventing a rate. Review time, sensor outages, changing modes and missing features independently. A review queue should preserve the raw observation and score, record human disposition, and avoid treating a flag as guilt. For streaming sensors, split chronologically and fit preprocessing only on available history. Labeling the reference as clean using later events is leakage.
False alarms versus recall
from fractions import Fractiony=[0,0,1,1]; flags=[0,1,0,1]print(Fraction(sum(a and not b for a,b in zip(flags,y)),y.count(0)),Fraction(sum(a and b for a,b in zip(flags,y)),y.count(1)))Expected output (locally tested): 1/2 1/2. The denominators are different reference populations.
Common mistakes
Never equate a high score with wrongdoing or probability. Do not count false alarms over all rows when reporting false-positive rate, or use final holdout labels to tune thresholds.
Practice and next steps
For scores [1,4,2,4] at threshold 4, compare inclusive and exclusive decisions. Suppose labels are [0,0,1,1]; calculate false-positive rate and recall for each rule.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Novelty versus outliers — knowledge check
Apply novelty versus outliers to small examples and debugging scenarios.
What is novelty detection?
What does an anomaly score establish?
Which denominator defines false-positive rate?
Which split suits a future sensor stream?
What should a flag trigger?