Feature extraction with feasts

Today let's understand how to boil a whole time series down into a handful of numbers, called features, so you can compare many series at once instead of eyeballing them one by one.

Victoria's retail sector reports monthly turnover, in millions of Australian dollars, for 20 different industries: department stores, liquor retailing, pharmaceutical and cosmetic retailing, takeaway food services, and 16 others besides. The Australian Bureau of Statistics has tracked every one of them since April 1982, 441 months per industry, right through to December 2018.

Below, each dot is one of those 20 industries, placed using two numbers computed from nothing but that industry's own 441 months of turnover.

That is what a feature does: it turns a series with hundreds of numbers into one number you can place directly against every other industry's. Each axis above is one such feature, computed once, the same way, for all 20 industries at once.

Twenty industries, one series each, too many to compare by eye

Look at four of Victoria's twenty retail industries side by side: liquor retailing, department stores, pharmaceutical and cosmetic retailing, and newspaper and book retailing.

RInteractive R
# Plot four Victoria retail industries side by side, each on its own scale library(tsibble) library(tsibbledata) library(dplyr) library(ggplot2) vic <- tsibbledata::aus_retail |> filter(State == "Victoria") four <- vic |> filter(Industry %in% c( "Liquor retailing", "Department stores", "Pharmaceutical, cosmetic and toiletry goods retailing", "Newspaper and book retailing" )) ggplot(four, aes(x = Month, y = Turnover)) + geom_line() + facet_wrap(vars(Industry), scales = "free_y", ncol = 1)

  

Each panel has its own scale, so look at the shape, not the height. Liquor retailing and department stores both climb with a sharp spike every December. Pharmaceutical and cosmetic retailing climbs too, but more smoothly, without as sharp a spike. Newspaper and book retailing looks the least tidy of the four: its climb wanders rather than holding one clean line.

Four industries already took four separate panels to compare. Victoria has 20. Eyeballing 20 panels, or worse, 20 separate plots, does not scale, and it hands you no actual number you could give to a colleague or feed into another script. What you need instead is one function that looks at every series and hands back a row of numbers per industry.