liveBook · Manning

Sampling

As explained in Outlier Detection in Python

Sampling is the selection of a subset of observations from a larger dataset for analysis or modeling.

Sampling selects a subset of records for analysis or model training. It reduces training time, but sample size trades speed against accuracy and must reflect feature complexity and interactions. section 10.2.1

Use sampling differently during training and prediction:

  • Train periodically on samples when the full dataset is unnecessarily expensive; test sample sizes with synthetic outliers to measure reliability and training time. section 10.2.1
  • Use smaller reference samples to accelerate distance-based prediction, accepting that larger reference sets are slower but often more accurate. section 10.2.1
  • Usually predict on every record, except when spot-checking is sufficient or investigation capacity limits the useful number of flagged anomalies. section 10.2.1
  • Preserve the full range of normal data when training one-class models; excluding rare but legitimate records can create false positives. section 5.4

Sampling within Isolation Forest

Isolation Forest uses small samples for each tree; a default size of 256 enables fast training and can reduce swamping and masking, although tight clusters of outliers may remain difficult to isolate. section 5.2

Figure 5.1 The training data for an Isolation Forest is divided randomly in each Isolation Tree. This shows the first three steps, resulting in eight nodes, each covering some subregion of the full dataspace. At this point (in the bottom right pane), one point (in the top right region) has already been isolated.

Shows how sampled training points are divided randomly through Isolation Trees until individual points or small groups become isolated. section 5.2

How Outlier Detection in Python covers it

How deep it goes
Explains sample-size trade-offs, synthetic-outlier testing, prediction exceptions, and normal-class coverage without prescribing a universal size.
Examples
Uses hundreds or thousands of training records, synthetic outliers, 256-point Isolation Forest samples, and full normal-class coverage.
What it assumes
Assumes familiarity with outlier detection and model prediction while teaching sample-size selection and normal-class representation.
What you can do after
Apply it via sampling-based outlier detectors while measuring reliability, preserving legitimate variation, and balancing speed against accuracy.
How it connects
Connects sampling with outlier detection, Isolation Forest, OCSVM, LOF, KNN, and LDOF.

Also explained in

Compare how 23 books explain sampling →

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.