ForecastV2Request
Parameters
samples
Type:List[List[SingleEvalSamplePayload]]
List of sample rows, where each row contains 1 or more time series samples (target + metadata). All samples in a row must have the same timestamps for consistency.
model
Type:str
Name of the model to use for forecasting. Must be a non-empty string. The model name is trimmed of whitespace.
Raises
ValueError
- If samples list is empty
- If any sample row is empty
- If samples in a row have mismatched timestamps
- If model name is empty or whitespace
Notes
- Each sample row represents a single forecast / forecasting scenario
- The model name is automatically trimmed of leading/trailing whitespace
- Samples are validated for consistency before processing
- All samples in a row must have matching timestamps
Examples
Multiple Sample Rows
Class Methods
from_dfs
Parameters
history_dfs
Type:List[pd.DataFrame]
List of DataFrames containing historical data. Each DataFrame represents one forecasting scenario.
target_dfs
Type:List[pd.DataFrame]
List of DataFrames containing target (future) data. Must have the same length as history_dfs.
target_col
Type:str
Name of the target column to forecast. Must exist in all DataFrames and cannot be in metadata_cols.
timestamp_col
Type:str
Name of the timestamp column. Must exist in all DataFrames and cannot be in metadata_cols.
metadata_cols
Type:List[str]
List of metadata column names. These columns provide context but are not forecasted. Cannot include target_col or timestamp_col.
leak_cols
Type:List[str]
List of columns that should be marked as leak_target=True. Must be a subset of metadata_cols.
model
Type:str
Name of the model to use for forecasting.
Raises
- ValueError: If history_dfs and target_dfs have different lengths
- ValueError: If any DataFrame is missing required columns
- ValueError: If all DataFrames don’t have consistent column structure
- ValueError: If leak_cols is not a subset of metadata_cols
- ValueError: If target_col or timestamp_col are in metadata_cols
- ValueError: If any DataFrame is empty
Notes
- All DataFrames must have the same column structure
- NaN values are automatically converted to None for JSON compatibility
- Each DataFrame pair (history_df, target_df) creates one sample row/forecast scenario
- Target column creates a forecast sample, metadata columns create metadata samples
- Leak columns are marked with leak_target=True
Example
from_dfs_pre_split
Parameters
dfs
Type:List[pd.DataFrame]
List of pandas DataFrames to process. Each DataFrame should contain time series data with a timestamp column and various feature columns.
timestamp_col
Type:str
Name of the column containing timestamps. This column will be converted to datetime format and used for splitting data into history and target periods.
target_cols
Type:List[str]
Column names to be used as forecast targets. These columns will have forecast=True in the resulting SingleEvalSamplePayload objects.
model
Type:str
Name of the model to use for forecasting.
cutoff_date
Type:Optional[str] Default: None
Date string (e.g., “2023-01-01”) to split data into history (≤ cutoff) and target (> cutoff) periods. Mutually exclusive with num_target_rows.
num_target_rows
Type:Optional[int] Default: None
Number of rows to use as target period (taken from the end of each DataFrame). Mutually exclusive with cutoff_date.
metadata_cols
Type:List[str] Default: []
Column names to be used as metadata/correlates. These columns will have metadata=True in the resulting SingleEvalSamplePayload objects.
leak_cols
Type:List[str] Default: []
Column names that are allowed to leak target information. Must be a subset of metadata_cols. These columns will have leak_target=True.
forecast_window
Type:Optional[Union[str, int]] Default: None
For backtesting: the size of the forecast window. If str, interpreted as pandas time offset (e.g., “7D” for 7 days). If int, interpreted as number of rows. Must be provided together with stride.
stride
Type:Optional[Union[str, int]] Default: None
For backtesting: the step size between consecutive forecasts. If str, interpreted as pandas time offset. If int, interpreted as number of rows. Must be provided together with forecast_window.
Raises
- ValueError: If both cutoff_date and num_target_rows are provided
- ValueError: If neither cutoff_date nor num_target_rows are provided
- ValueError: If forecast_window is provided without stride or vice versa
- ValueError: If no history rows are found for the given cutoff_date
- ValueError: If type mismatches occur (e.g., string vs int for forecast_window/stride)
- ValueError: If leak_cols is not a subset of metadata_cols
- ValueError: If target_cols overlap with metadata_cols
Processing Modes
The method supports four processing modes:- Single window by date: cutoff_date provided, no forecast_window/stride
- Single window by rows: num_target_rows provided, no forecast_window/stride
- Backtesting by date: cutoff_date + forecast_window/stride (all strings)
- Backtesting by rows: num_target_rows + forecast_window/stride (all integers)
Examples
Single window by date:See Also
- SingleEvalSamplePayload : Individual time series sample
- ForecastV2Response : Response containing forecast results
- from_dfs : Create request from pandas DataFrames
- from_dfs_pre_split : Create request with backtesting support