feasts: Feature Extraction And Statistics for Time Series

repository·main·Indexed 43 days ago

https://github.com/tidyverts/feasts

A collection of tools for the analysis of time series data within the tidyverts ecosystem. It works with tidy temporal data from the tsibble package to provide time series features, decompositions (such as STL and Classical), statistical summaries, and visualizations using ggplot2, including seasonal, subseries, and lag plots.

Tokens
670
Snippets
4
Records
5
Agent score
5%

What's inside feasts

  1. Overview of feasts

    main

    feasts (Feature Extraction And Statistics for Time Series) is a collection of tools for the analysis of time series data. It works with tidy temporal data provided by the tsibble package to produce:

    • Time series features
    • Decompositions
    • Statistical summaries
    • Convenient visualisations

    It is designed to integrate closely with the tidy forecasting workflow used in the fable package.

  2. Extract features and statistics from time series

    main

    You can extract features and statistics across a large collection of time series using the features() function. This is useful for identifying unusual/extreme time series or finding clusters of similar behavior.

    Example: Extracting STL features from retail turnover data:

    as_retail %>%
      features(Turnover, feat_stl)

    Extracted features can then be used for visualization (e.g., plotting feature strengths) or filtering to find extreme cases (e.g., the most or least seasonal series).

    aus_retail %>%
      features(Turnover, feat_stl)
  3. Install feasts

    main

    You can install the stable version of feasts from CRAN or the development version from GitHub.

    Stable version (CRAN):

    install.packages("feasts")

    Development version (GitHub):

    # install.packages("remotes")
    remotes::install_github("tidyverts/feasts")
    install.packages("feasts")
  4. Visualize time series patterns with feasts graphics

    main

    The package uses ggplot2 to provide customisable graphics for understanding time series patterns. Common tasks include:

    • Seasonal plots: Use gg_season() to visualize seasonality.
    • Subseries plots: Use gg_subseries() to visualize subseries patterns.
    • Lag plots: Use gg_lag() to visualize lags.
    • Autocorrelation plots: Use ACF() combined with autoplot() to visualize autocorrelation.

    Example usage:

    # Seasonal plot
    aus_production %>% gg_season(Beer)
    
    # Subseries plot
    aus_production %>% gg_subseries(Beer)
    
    # Lag plot
    aus_production %>% filter(year(Quarter) > 1991) %>% gg_lag(Beer)
    
    # Autocorrelation plot
    aus_production %>% ACF(Beer) %>% autoplot()
    aus_production %>% gg_season(Beer)
  5. Decompose time series using STL or Classical methods

    main

    feasts supports decomposing a time series into simpler components (such as trend, season, and remainder) using methods like Classical decomposition and STL decomposition.

    To perform decomposition, use the model() function with a decomposition method (e.g., STL()), then extract the components using components().

    # Perform STL decomposition
    dcmp <- aus_production %>%
      model(STL(Beer ~ season(window = Inf)))
    
    # Extract components
    components(dcmp)
    
    # Plot components
    components(dcmp) %>% autoplot()
    dcmp <- aus_production %>%
      model(STL(Beer ~ season(window = Inf)))
    components(dcmp)