Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Multi-Output Forecasting | Multi-Step Forecasting Strategies
Quizzes & Challenges
Quizzes
Challenges
/
Machine Learning for Time Series Forecasting

bookMulti-Output Forecasting

Multi-output regression is a powerful approach in time series forecasting that enables you to predict several future time points simultaneously, rather than just the next step. Instead of training a separate model for each forecast horizon or chaining predictions recursively, you train a single model that outputs a vector of future values in one shot. This method can be especially useful when you want to generate forecasts for multiple time steps ahead and capture dependencies between those future values.

123456789101112131415161718192021222324252627282930313233
import numpy as np from sklearn.ensemble import RandomForestRegressor from sklearn.multioutput import MultiOutputRegressor from sklearn.model_selection import train_test_split # Generate dummy time series data np.random.seed(42) n_samples = 300 window_size = 10 n_outputs = 3 # predict next 3 time steps # Create input windows and corresponding targets X = [] y = [] series = np.cumsum(np.random.randn(n_samples + window_size + n_outputs)) for i in range(n_samples): X.append(series[i:i+window_size]) y.append(series[i+window_size:i+window_size+n_outputs]) X = np.array(X) y = np.array(y) # Split data X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, shuffle=False) # Build and train multi-output regressor base_regressor = RandomForestRegressor(n_estimators=100, random_state=42) multi_output_model = MultiOutputRegressor(base_regressor) multi_output_model.fit(X_train, y_train) # Predict next 3 steps for the test set y_pred = multi_output_model.predict(X_test) print("Predicted shape:", y_pred.shape) # Should be (n_test_samples, 3) print("First prediction:", y_pred[0])
copy

Multi-output forecasting offers clear benefits in certain scenarios. By predicting several future steps at once, you reduce error propagation that can occur in recursive strategies, where each prediction depends on the previous one. This approach can also capture the joint structure and dependencies among future values, which is often missed when using separate direct models for each horizon. However, multi-output models come with some limitations. They typically require more data to train effectively, since the model must learn to predict a higher-dimensional output. The model complexity also increases, making it more prone to overfitting if not managed carefully. Additionally, as the number of forecast steps grows, it becomes increasingly challenging for a single model to accurately capture all future dependencies, especially in highly volatile or non-stationary series.

1. What is a benefit of multi-output forecasting compared to recursive and direct strategies?

2. What challenge arises when using multi-output models for long forecast horizons?

question mark

What is a benefit of multi-output forecasting compared to recursive and direct strategies?

Select the correct answer

question mark

What challenge arises when using multi-output models for long forecast horizons?

Select the correct answer

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 3. Розділ 3

Запитати АІ

expand

Запитати АІ

ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

bookMulti-Output Forecasting

Свайпніть щоб показати меню

Multi-output regression is a powerful approach in time series forecasting that enables you to predict several future time points simultaneously, rather than just the next step. Instead of training a separate model for each forecast horizon or chaining predictions recursively, you train a single model that outputs a vector of future values in one shot. This method can be especially useful when you want to generate forecasts for multiple time steps ahead and capture dependencies between those future values.

123456789101112131415161718192021222324252627282930313233
import numpy as np from sklearn.ensemble import RandomForestRegressor from sklearn.multioutput import MultiOutputRegressor from sklearn.model_selection import train_test_split # Generate dummy time series data np.random.seed(42) n_samples = 300 window_size = 10 n_outputs = 3 # predict next 3 time steps # Create input windows and corresponding targets X = [] y = [] series = np.cumsum(np.random.randn(n_samples + window_size + n_outputs)) for i in range(n_samples): X.append(series[i:i+window_size]) y.append(series[i+window_size:i+window_size+n_outputs]) X = np.array(X) y = np.array(y) # Split data X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, shuffle=False) # Build and train multi-output regressor base_regressor = RandomForestRegressor(n_estimators=100, random_state=42) multi_output_model = MultiOutputRegressor(base_regressor) multi_output_model.fit(X_train, y_train) # Predict next 3 steps for the test set y_pred = multi_output_model.predict(X_test) print("Predicted shape:", y_pred.shape) # Should be (n_test_samples, 3) print("First prediction:", y_pred[0])
copy

Multi-output forecasting offers clear benefits in certain scenarios. By predicting several future steps at once, you reduce error propagation that can occur in recursive strategies, where each prediction depends on the previous one. This approach can also capture the joint structure and dependencies among future values, which is often missed when using separate direct models for each horizon. However, multi-output models come with some limitations. They typically require more data to train effectively, since the model must learn to predict a higher-dimensional output. The model complexity also increases, making it more prone to overfitting if not managed carefully. Additionally, as the number of forecast steps grows, it becomes increasingly challenging for a single model to accurately capture all future dependencies, especially in highly volatile or non-stationary series.

1. What is a benefit of multi-output forecasting compared to recursive and direct strategies?

2. What challenge arises when using multi-output models for long forecast horizons?

question mark

What is a benefit of multi-output forecasting compared to recursive and direct strategies?

Select the correct answer

question mark

What challenge arises when using multi-output models for long forecast horizons?

Select the correct answer

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 3. Розділ 3
some-alt