Skip to main content

tft

Perform TFT forecast (Temporal Fusion Transformer): https://unit8co.github.io/darts/generated_api/darts.models.forecasting.tft_model.html

Usageโ€‹

tft [--lstm-layers LSTM_LAYERS] [--num-attention-heads NUM_ATTENTION_HEADS] [--full-attention] [--hidden-continuous-size HIDDEN_CONTINUOUS_SIZE] [--hidden-size HIDDEN_SIZE] [--past-covariates PAST_COVARIATES] [--all-past-covariates] [--naive] [-d {AAPL}] [-c TARGET_COLUMN] [-n N_DAYS] [-t TRAIN_SPLIT] [-i INPUT_CHUNK_LENGTH] [-o OUTPUT_CHUNK_LENGTH] [--force-reset FORCE_RESET] [--save-checkpoints SAVE_CHECKPOINTS] [--model-save-name MODEL_SAVE_NAME] [--n-epochs N_EPOCHS] [--dropout DROPOUT] [--batch-size BATCH_SIZE] [--end S_END_DATE] [--start S_START_DATE] [--residuals] [--forecast-only] [--export-pred-raw] [--metric {rmse,mse,mape,smape}]

Parametersโ€‹

NameParameterDescriptionDefaultOptionalChoices
lstm_layers--lstm-layersNumber of LSTM layers.1TrueNone
num_attention_heads--num-attention-headsNumber of attention heads.4TrueNone
full_attention--full-attentionWhether to apply a multi-head attention query.FalseTrueNone
hidden_continuous_size--hidden-continuous-sizeDefault hidden size for processing continuous variables.8TrueNone
hidden_size--hidden-sizeSize for feature maps for each hidden RNN layer (h_n)16TrueNone
past_covariates--past-covariatesPast covariates(columns/features) in same dataset. Comma separated.NoneTrueNone
all_past_covariates--all-past-covariatesAdds all rows as past covariates except for date and the target column.FalseTrueNone
naive--naiveShow the naive baseline for a model.FalseTrueNone
target_dataset-d --datasetThe name of the dataset you want to selectNoneTrueAAPL
target_column-c --target-columnThe name of the specific column you want to usecloseTrueNone
n_days-n --n-daysprediction days.5TrueNone
train_split-t --train-splitStart point for rolling training and forecast window. 0.0-1.00.85TrueNone
input_chunk_length-i --input-chunk-lengthNumber of past time steps for forecasting module at prediction time.14TrueNone
output_chunk_length-o --output-chunk-lengthThe length of the forecast of the model.5TrueNone
force_reset--force-resetIf set to True, any previously-existing model with the same name will be reset (all checkpoints will be discarded).TrueTrueNone
save_checkpoints--save-checkpointsWhether to automatically save the untrained model and checkpoints.TrueTrueNone
model_save_name--model-save-nameName of the model to save.tft_modelTrueNone
n_epochs--n-epochsNumber of epochs over which to train the model.300TrueNone
dropout--dropoutFraction of neurons affected by Dropout, from 0 to 1.0.1TrueNone
batch_size--batch-sizeNumber of time series (input and output) used in each training pass32TrueNone
s_end_date--endThe end date (format YYYY-MM-DD) to select for testingNoneTrueNone
s_start_date--startThe start date (format YYYY-MM-DD) to select for testingNoneTrueNone
residuals--residualsShow the residuals for the model.FalseTrueNone
forecast_only--forecast-onlyDo not plot the historical data without forecasts.FalseTrueNone
export_pred_raw--export-pred-rawExport predictions to a csv file.FalseTrueNone
metric--metricCalculate precision based on a specific metric (rmse, mse, mape)mapeTruermse, mse, mape, smape

Examplesโ€‹

2022 Jul 23, 10:36 (๐Ÿฆ‹) /forecast/ $ load GME_20220719_123734.csv -a GME

2022 Jul 23, 11:03 (๐Ÿฆ‹) /forecast/ $ tft GME
100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 115/115 [00:0700:00, 15.10it/s]
TFT model obtains MAPE: 44.60%



Actual price: $ 146.64
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
โ”ƒ Datetime โ”ƒ Prediction โ”ƒ
โ”กโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ฉ
โ”‚ 2022-07-19 00:00:00 โ”‚ $ 169.69 โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ 2022-07-20 00:00:00 โ”‚ $ 168.53 โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ 2022-07-21 00:00:00 โ”‚ $ 167.33 โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ 2022-07-22 00:00:00 โ”‚ $ 167.23 โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ 2022-07-25 00:00:00 โ”‚ $ 165.82 โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

tft