Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Challenge: Visualizing Time Series Components | Foundations of Time Series Analysis
Time Series Forecasting with ARIMA

bookChallenge: Visualizing Time Series Components

Opgave

Swipe to start coding

Your goal is to decompose a time series into its componentstrend, seasonality, and residuals — using the seasonal_decompose() function from statsmodels.

  1. Load the built-in "flights" dataset from seaborn.
  2. Extract the "passengers" column as your target time series.
  3. Apply seasonal_decompose() with an additive model and a period of 12 (months).
  4. Store the result in a variable called decomposition.
  5. Plot the original series, trend, seasonal, and residual components.

seasonal_decompose(series, model="additive", period=12) automatically splits the time series into four parts:

  • trend → long-term movement;
  • seasonal → repeating patterns;
  • resid → random noise;
  • observed → original data.

Each component can be accessed with attributes like .trend, .seasonal, .resid.

Løsning

Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 1. Kapitel 4
single

single

Spørg AI

expand

Spørg AI

ChatGPT

Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat

close

Awesome!

Completion rate improved to 6.67

bookChallenge: Visualizing Time Series Components

Stryg for at vise menuen

Opgave

Swipe to start coding

Your goal is to decompose a time series into its componentstrend, seasonality, and residuals — using the seasonal_decompose() function from statsmodels.

  1. Load the built-in "flights" dataset from seaborn.
  2. Extract the "passengers" column as your target time series.
  3. Apply seasonal_decompose() with an additive model and a period of 12 (months).
  4. Store the result in a variable called decomposition.
  5. Plot the original series, trend, seasonal, and residual components.

seasonal_decompose(series, model="additive", period=12) automatically splits the time series into four parts:

  • trend → long-term movement;
  • seasonal → repeating patterns;
  • resid → random noise;
  • observed → original data.

Each component can be accessed with attributes like .trend, .seasonal, .resid.

Løsning

Switch to desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 1. Kapitel 4
single

single

some-alt