TADiff: The implementation codes of "What if Tomorrow is the World Cup Final? Counterfactual Time Series Forecasting with Textual Conditions" 📈
ICML 2026
We propose TADiff, a counterfactual time series forecasting model with text-attribution mechanism.
To achieve balanced forecasting considering the combined effects of history and future, we propose a text-attribution mechanism that attributes historical sequences prior to forecasting, aiming to decouple the intrinsic features of the sequence from the extrinsic conditions. The overall process consists of a two-stage inference and a joint training with two optimization objectives.
We propose DTTC scores, the model-based evaluation metrics for counterfactual time sries forecasting, even when the ground truth time series is absent. The DTTC scores consist of DTTC-I and DTTC-E, measuring the consistency of forecasts with intrinsic historical featues and extrinsic future condtions, respectively.
We compare our method, TADiff, with the baselines on both synthetic and real-world datasets. We consider both the factual forecasting and counterfactual forecasting. As shown in the table below, TADiff achieves both superior numerical accuracy and semantic consistency. Moreover, TADiff exhibits strong adaptability and generalization for forecasting under diverse future conditions.
torch==2.6.0
pandas==2.0.3
pyyaml==6.0.3
linear_attention_transformer==0.19.1
tensorboard==2.20.0
scikit-learn==1.7.2
You can use the following command to prepare your environment.
pip install -r requirements.txt
Download the datasets from Google Drive.
Assume the datasets are in `/path/to/dataset/`. It should be like:
/path/to/dataset/:
Synth/:
F/:
train_ts.npy
train_attrs.npy
train_caps.npy
...
CF/:
train_ts.npy
train_attrs.npy
train_caps.npy
...
ETTm1/:
...
NOTE: The arg --data_folder=/path/to/dataset/ should be passed to the training script.
Download the LongCLIP from Huggingface, and put the model weights in /path/to/save/.
Download the checkpoints of DTTC model from Google Drive.
Assume the checkpoints are in `/path/to/save/`. It should be like:
/path/to/save/:
[dataset_name]_cttp:
...
[dataset_name]_eval:
[run_id]:
ckpts:
model_best.pth
train_configs.yaml
eval_configs.yaml
model_cond_configs.yaml
model_diff_configs.yaml
...
...
NOTE: The arg --save_folder=/path/to/save/ should be passed to the training script.
To pretrain the model on the factual data and finetune the model on the counterfactual data.
bash scripts/{dataset_name}/pretrain.sh
bash scripts/{dataset_name}/finetune.sh
To evaluate the model with the checkpoints under factual and counterfactual settings.
bash scripts/{dataset_name}/eval_f.sh
bash scripts/{dataset_name}/eval_cf.sh
After the training, check the results at the following path.
{save_folder}/{run_id}/results.csv
All codes in this repository run on GPU by default. If you need to run on the CPU, please modify the device-related parameters in the config file.
This project is licensed under the MIT License - see the LICENSE file for details.
If our work helps you in research, please give us a star or cite us using the following:
@article{gu2026tadiff,
title={What if Tomorrow is the World Cup Final? Counterfactual Time Series Forecasting with Textual Conditions},
author={Gu, Shuqi and Zhao, Yongxiang and Jing, Baoyu and Ren, Kan},
journal={International Conference on Machine Learning},
year={2026}
}


