liveBook · Manning

Histogram-based outlier score

As explained in Outlier Detection in Python

Histogram-based outlier score (HBOS) is an outlier-detection algorithm that scores observations by combining the rarity of their values in independently binned feature distributions.

Histogram-based outlier score (HBOS) detects unusual observations by examining each feature independently and combining the rarity of values across their binned distributions. Its main advantage is speed, but it identifies univariate outliers rather than rare combinations of features. section 6.2

Use HBOS when:

  • Data contains many features and testing multiple features together is impractical. section 6.2
  • Features have little association, or manually reviewing every flagged observation makes additional subtle detections less useful. section 6.2
  • Avoid treating its flags as automatically meaningful: subtle multivariate outliers may be missed, and domain experts may be needed to judge unusual values. section 6.2

Speech-feature screening

A speech dataset contains 400 i-vector features representing segments of spoken English. HBOS can quickly score the records, while a score histogram shows the score distribution. A 99.5th-percentile cutoff can label candidate outliers for follow-up; plotting feature distributions for flagged and unflagged records helps investigate which variables differ. section 6.2

Listing 6.4 Using HBOS with the speech dataset
import pandas as pd
from pyod.models.hbos import HBOS
from sklearn.datasets import fetch_openml
import matplotlib.pyplot as plt
import seaborn as sns
 
data = fetch_openml(“speech”, version=1, parser='auto')
df = pd.DataFrame(data.data, columns=data.feature_names)
print(df.head())
 
det = HBOS()
det.fit(df)
pred = det.decision_scores_
 
sns.histplot(pred)
plt.show()

Shows a concise PyOD workflow: load the OpenML speech dataset, fit HBOS, and inspect decision scores. section 6.2

How Outlier Detection in Python covers it

How deep it goes
Explains independent feature analysis, practical trade-offs, scoring inspection, and follow-up plots, but not the scoring derivation.
Examples
Uses OpenML speech i-vectors, score histograms, percentile labels, and feature-distribution comparisons.
What it assumes
Assumes tabular feature data and requires domain judgment to determine whether flagged observations are genuinely unusual.
What you can do after
Apply it via PyOD, generate decision scores, select candidate flags, and investigate feature differences.
How it connects
Contrasts univariate outlier detection with multivariate tests and can be applied within clusters.

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.