Using Command-Line Tools¶
fusionlab provides convenient command-line interface (CLI) tools,
typically located in the fusionlab/tools/ directory of the
installation. These tools allow you to run standard training and
prediction workflows directly from your terminal without writing custom
Python scripts, making common tasks faster and more reproducible.
This page provides examples based on the tools described in the Command-Line Interface (CLI) section. Remember to replace placeholder paths like path/to/fusionlab/tools/ with the actual location in your environment.
Using the General TFT CLI (tft_cli.py)¶
This is the recommended tool for general-purpose training and prediction
with the TemporalFusionTransformer
due to its configurability.
Example: Training a Quantile TFT Model
This command trains a TFT model for quantile forecasting, specifying data paths, features, sequence parameters, training settings, and output locations.
1python path/to/fusionlab/tools/tft_cli.py \
2 --mode train \
3 --data path/to/your_training_data.csv \
4 --target Sales \
5 --dt_col Date \
6 --dynamic_features Price Promotion Temperature \
7 --static_features StoreID Region \
8 --future_features PlannedHoliday \
9 --time_steps 24 \
10 --forecast_horizon 12 \
11 --quantiles 0.1 0.5 0.9 \
12 --epochs 75 \
13 --batch_size 64 \
14 --learning_rate 0.002 \
15 --hidden_units 64 \
16 --num_heads 4 \
17 --patience 15 \
18 --output_dir ./tft_training_run1 \
19 --model_name my_sales_tft \
20 --verbose 1
Example: Generating Predictions with the Trained TFT Model
This command uses the model and scalers saved during the training run to generate forecasts. It loads the necessary artifacts and historical data to prepare prediction inputs.
1python path/to/fusionlab/tools/tft_cli.py \
2 --mode predict \
3 --data path/to/your_LATEST_historical_data.csv \
4 --target Sales \
5 --dt_col Date \
6 --dynamic_features Price Promotion Temperature \
7 --static_features StoreID Region \
8 --future_features PlannedHoliday \
9 --time_steps 24 \
10 --forecast_horizon 12 \
11 --load_model_path ./tft_training_run1/my_sales_tft_best.keras \
12 --load_scalers_path ./tft_training_run1/scalers.joblib \
13 --quantiles 0.1 0.5 0.9 \
14 --predictions_output_file ./tft_training_run1/forecast_output.csv \
15 --verbose 1
Running Specific Application Scripts (Example)¶
These scripts might be less configurable but demonstrate specific, potentially pre-configured, workflows.
Example: Running the Deterministic XTFT Application
This script (as documented previously) has most parameters hardcoded and mainly accepts a verbosity level.
1# Run with detailed DEBUG logging
2python path/to/fusionlab/tools/xtft_determinic_p.py --verbose 2
3
4# Run with standard INFO logging
5python path/to/fusionlab/tools/xtft_determinic_p.py --verbose 1