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

bookChallenge: Visualizing Time Series Components

Uppgift

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 allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 1. Kapitel 4
single

single

Fråga AI

expand

Fråga AI

ChatGPT

Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal

close

Awesome!

Completion rate improved to 6.67

bookChallenge: Visualizing Time Series Components

Svep för att visa menyn

Uppgift

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 desktopByt till skrivbordet för praktisk övningFortsätt där du är med ett av alternativen nedan
Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 1. Kapitel 4
single

single

some-alt