liveBook · Manning

Time scale

As explained in Outlier Detection in Python

A temporal resolution or interval over which observations are grouped and analyzed.

A time scale is the temporal resolution used to group and analyze observations. Examining multiple scales can reveal collective outliers hidden at another granularity: hours may look normal while their daily total is unusual. section 12.6.3

Choose and interpret time scales cautiously:

  • Compare hours, days, and months when anomalies may emerge only after aggregation. section 12.6.3
  • Account for multiple testing: examining many short periods can produce false positives, especially with few records per period. section 12.6.3
  • Require enough observations for reliable comparisons; aggregated collective-outlier tests can become more stable when each row summarizes many records. section 12.6.3
Listing 12.4 Creating a table where each row represents one day
purchases_df.groupby(['Date']).agg({
     'Count': ['mean', 'sum'], 
     'Unit Cost': ['mean', 'sum'],
     'Total Cost': ['mean', 'sum'],  
     'Purchase ID': ['count']})

Create one row per day by aggregating purchase counts, costs, and purchase totals. section 12.6.3

Purchase data

Daily aggregation exposes unusual days that hourly inspection may miss. In a calendar-day comparison, the 28th appears unusually high but is not a strong outlier; the 31st is low because it occurs in fewer months. section 12.6.3

How Outlier Detection in Python covers it

How deep it goes
Explains multiscale aggregation, sample-size limitations, multiple-testing risks, and daily feature construction without deriving detection algorithms.
Examples
Uses purchase records grouped by hour, day, month, calendar day, and seconds, including an unusually high 28th day.
What it assumes
Assumes time-stamped records and basic aggregation, while demonstrating how to engineer summary features for each period.
What you can do after
Apply aggregation to construct daily comparison tables and interpret flagged periods with attention to evidence strength.
How it connects
Connects time scales with collective outliers, point anomalies, aggregation, multiple testing, and feature engineering.

Also explained in

Compare how 2 books explain time scale →

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.