Introduction | Terminology | Models |
Darts is an open source Python library designed to make the use of [modeling] easy. Using any of the models is easy because they all have standard .fit(), .predict(), .plot(), and other methods with arguments that are mostly common among the models. Default arguments for these modeling methods have been established that will get a beginner close to a good model quickly. Multiple time series and multivariate series can be consumed by many of the models, as well as the inclusion of related past, future, and static data. The Darts excellent online documentation provides details on the capabilities of each model, and many examples of their use with Darts data sets.
https://github.com/unit8co/darts/issues
Model | Target Series: Univariate / Multivariate |
Covariates: Past / Future / Static |
Training & Forecasting on Multiple Series |
Required / Supported Arguments | Supports val_series in .fit() |
---|---|---|---|---|---|
AutoARIMA | ☆ ☓ | ☓ ☆ ☓ | ☓ | m(seasonal=True, m=seasonal_period) |
☓ |
StatsForecastAutoArima | ☆ ☓ | ☓ ☆ ☓ | ☓ | m(seasonal=True, season_length=seasonal_period | ☓ |
LFM CatBoostModel |
☆ ☆ | ☆ ☆ | ☆ | model(lags=20, lags_future_covariates=(1,10) |
☓ |
TFM TFTModel |
☆ ★ ☆ | model(input_chunk_length, output_chunk_length) model.fit(series,future_covariates) model.predict(future_covariates) |
|||
TFM RNNModel |
☆ | model(input_chunk_length, output_chunk_length=1, training_length) |
|||
TFM TCNModel |
☆ | output_chunk_length < kernel_size < input_chunk_length |
TFM Torch Forecasting Model - PyTorch (Lightning)-based Models
☓ not supported | ☆ supported | ★ required |
from darts.utils.statistics import plot_acf, check_seasonality
plot_acf(ts, m=12, alpha=0.05)
# Check for gaps in the index caused by NaN/NaT
if index_has_gaps(ts.pd_dataframe()): raise Exception("ts has gaps in the index likely caused by NaN/NaT")
# Check the series components/columns for NaN/NaT values and attempt to resolve if found.
if df_has_nan_or_nat(ts.pd_dataframe(), False, False):
len_ts = len(ts)
ts = ts.longest_contiguous_slice()
print("WARNING: extracted longest continguous slice without NaN/NaT, series was " + str(len_ts) + " rows, now " + str(len(ts)), "\n")
"""
# Alternative method of dealing with NaN/NaT
print("WARNING: Dropping these rows with NaN/NaT:")
df = ts.pd_dataframe()
# print the rows that have NaN/NaT
#print(df[df.isnull().any(axis=1)])
# drop the rows with NaN/NaT
df.dropna(inplace=True)
# Create ts from df, but fix missing dates created by .dropna()
#ts = TimeSeries.from_dataframe(df, fill_missing_dates=True)
"""
if index_has_gaps(ts.pd_dataframe()): raise Exception("The series has one or more columns with NaN / NaT values that cannot be easily reconciled")
"ValueError: Prediction must have `end` after `start`"
The time after the prediction period is too short to accommodate the future covariate. Adjust the target series and/or the prediction period (n) so that the duration from the end of the prediction period (forecast horizon) to the end of the future covariates is >eq; the prediction period (n) for local forecasting models (LFM). IMPORTANT: make sure the prediction steps (n) is a integer! n = int(seasonal_period*2+1).
Python Solutions
Sitemap | Copyright © 2017 - 2025 Mechatronic Solutions LLC
Web site by www.MechatronicSolutionsLLC.com | | 21.3020 ms