liveBook · Manning

Discretization

As explained in Outlier Detection in Python

Binning is the process of assigning continuous or otherwise detailed values to discrete intervals or categories.

Binning converts continuous or detailed values into discrete intervals or categories. It prepares numeric data for outlier detectors that rely on histograms or categorical features. section 3.2.4 section 9.6

Choose a binning method to fit the outlier-detection task:

  • Use equal-width bins generally for univariate outliers, where the count in each bin can indicate how rare a value is. section 9.6
  • Use equal-count bins generally for multivariate outliers, focusing on rare combinations while assuming univariate outliers are tested elsewhere. section 9.6
  • Check sensitivity to extreme values and bin count: equal-width bins can compress ordinary values into edge bins, leave gaps, or hide an outlier among inliers. section 9.6

Interpretable categories for expense records

An outlier-detection example converts dates to day-of-month categories, times to hour categories, and amounts to categories based on their number of digits. These choices make the resulting frequent-itemset analysis more interpretable. section 3.2.4

Figure 9.1 The effect of the number of bins. In the first row we see where 20 bins are used and in the second row, 50 bins. In each row we see a distribution of uniform data with no outliers (left pane), with a single outlier with value 3.0 (middle pane), and with a second outlier with value 100.0 (right pane). In the top-right pane we see, using 20 bins, the 3.0 value is placed in a bin with inliers. In the bottom-right pane we see, using 50 bins, the 3.0 value is in a separate bin with low count so will be recognized as an outlier.

Compare how 20 versus 50 equal-width bins place uniform data and outliers at 3.0 and 100.0; the example shows how bin count can change whether an outlier shares a bin with inliers. section 9.6

How Outlier Detection in Python covers it

How deep it goes
Compares equal-width and equal-count methods, their uses, and sensitivity to extreme values and bin count.
Examples
Uses staff expense dates, times, and amounts, plus uniform data with outliers, to demonstrate binning choices.
What you can do after
Apply equal-width or equal-count bins while accounting for the detection task and possible effects of extreme values.
How it connects
Connects binning to histogram-based outlier detection, categorical outlier detection, frequent itemset mining, and ensemble learning.

Also explained in

Compare how 5 books explain discretization →

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.