MIDASWrapper
Python template · sinapsis_darts_forecasting.templates.time_series_preprocessing
Overview
A dynamic preprocessing template for applying Darts transformations to time series data.
This template allows users to apply various transformations from `darts.dataprocessing.transformers` to different parts of the time series packet (`content`, `past_covariates`, `future_covariates`).
If a transformer requires fitting (e.g., `Scaler`), it stores and retrieves transformation parameters.
MIDAS — inherited documentation
Helper class that provides a standard way to create an ABC using inheritance.Mixed-data sampling transformer.
A transformer that converts higher frequency time series to lower frequency using mixed-data sampling; see [1]_ for further details. This allows higher frequency covariates to be used whilst forecasting a lower frequency target series. For example, using monthly inputs to forecast a quarterly target.
Notes ----- The high input frequency should always relate in the same rate to the low target frequency. For example, there's always three months in quarter. However, the number of days in a month varies per month. In the latter case a MIDAS transformation does not work and the transformer will raise an error.
For anchored low frequency, the transformed series must contain at least 2 samples in order to be able to retrieve the original time index.
Parameters ---------- low_freq The pd.DateOffset string alias corresponding to the target low frequency [2]_. Passed on to the `rule` parameter of pandas.DataFrame.resample(). strip Whether to remove the NaNs from the start and the end of the transformed series. drop_static_covariates If set to `True`, the statics covariates of the input series won't be transferred to the output. This might be useful for multivariate series with component-specific static covariates. name A specific name for the scaler n_jobs The number of jobs to run in parallel. Parallel jobs are created only when a ``Sequence[TimeSeries]`` is passed as input to a method, parallelizing operations regarding different ``TimeSeries``. Defaults to `1` (sequential). Setting the parameter to `-1` means using all the available processors. Note: for a small amount of data, the parallelization overhead could end up increasing the total required amount of time. verbose Optionally, whether to print operations progress
Examples -------- >>> from darts.datasets import AirPassengersDataset >>> from darts.dataprocessing.transformers import MIDAS >>> monthly_series = AirPassengersDataset().load() >>> print(monthly_series.time_index[:4]) DatetimeIndex(['1949-01-01', '1949-02-01', '1949-03-01', '1949-04-01'], dtype='datetime64[ns]', name='Month', freq='MS') >>> print(monthly_series.values()[:4]) [[112.] [118.] [132.] [129.]] >>> midas = MIDAS(low_freq="QS") >>> quarterly_series = midas.fit_transform(monthly_series) >>> print(quarterly_series.time_index[:3]) DatetimeIndex(['1949-01-01', '1949-04-01', '1949-07-01'], dtype='datetime64[ns]', name='Month', freq='QS-JAN') >>> print(quarterly_series.values()[:3]) [[112. 118. 132.] [129. 121. 135.] [148. 148. 136.]] >>> inversed_quaterly = midas.inverse_transform(quarterly_series) >>> print(inversed_quaterly.time_index[:4]) DatetimeIndex(['1949-01-01', '1949-02-01', '1949-03-01', '1949-04-01'], dtype='datetime64[ns]', name='Month', freq='MS') >>> print(inversed_quaterly.values()[:4]) [[112.] [118.] [132.] [129.]]
References ---------- .. [1] https://en.wikipedia.org/wiki/Mixed-data_sampling .. [2] https://pandas.pydata.org/docs/user_guide/timeseries.html#dateoffset-objects
Capabilities
Capabilities: not setInstallation
Install the published package using pip or uv.
pip install sinapsis-darts-forecasting==1.0.0uv pip install sinapsis-darts-forecasting==1.0.0uv add sinapsis-darts-forecasting==1.0.0Configuration
Effective fields from the inspector schema, including nested Pydantic model fields.
Required
Default: null
Required
Default: null
Optional
Default: null
Required
Default: null
Optional
Default: "MIDAS"
Optional
Default: true
Optional
Default: 1
Optional
Default: false
Optional
Default: null
Optional
Default: false
Optional
Default: null
Optional
Default: null
Configuration example
Generated from documented defaults. Replace any placeholders and complete required nested settings before running.
templates:
- template_name: "MIDASWrapper"
class_name: "MIDASWrapper"
attributes:
method: "<required>"
apply_to: "<required>"
midas_init:
name: "MIDAS"
strip: true
n_jobs: 1
verbose: false
low_freq: null
drop_static_covariates: false
params_key: null
transform_kwargs: null
View original docstring example
The source example references MissingValuesFillerWrapper, not MIDASWrapper.
agent:
name: my_test_agent
templates:
- template_name: InputTemplate
class_name: InputTemplate
attributes: {}
- template_name: MissingValuesFillerWrapper
class_name: MissingValuesFillerWrapper
template_input: InputTemplate
attributes:
method: "transform"
apply_to: ["content"]
transform_kwargs:
method: "linear"
missingvaluesfiller_init:
fill: "auto"
name: "MissingValuesFiller"
n_jobs: 1
verbose: False
For a full list of options use the sinapsis cli: sinapsis info --all-template-names
If you want to see all available transformers, please visit: https://unit8co.github.io/darts/generated_api/darts.dataprocessing.transformers.htmlInheritance
sinapsis_darts_forecasting.templates.time_series_preprocessing.TimeSeriesPreprocessorEnvironment variables
Environment definitions belong to their canonical Python modules.