tft
tft
¶
Temporal Fusion Transformer (TFT) inference adapter.
This module provides optional deep-learning inference for FPLX using
pytorch-forecasting.
TFTQuantilePredictions
dataclass
¶
Container for TFT quantile outputs for a single gameweek.
to_optimizer_inputs
¶
Map quantiles to objective mean and downside risk.
| RETURNS | DESCRIPTION |
|---|---|
expected_points
|
Uses q50 as robust expected value proxy.
TYPE:
|
downside_risk
|
Uses q50 - q10 as downside spread.
TYPE:
|
Source code in fplx/inference/tft.py
TFTForecaster
¶
TFTForecaster(
quantiles: tuple[float, float, float] = (0.1, 0.5, 0.9),
encoder_length: int = 15,
prediction_length: int = 1,
)
Wrapper around PyTorch Forecasting's TemporalFusionTransformer.
Source code in fplx/inference/tft.py
fit
¶
fit(
panel_df: DataFrame,
training_cutoff: int,
max_epochs: int = 20,
batch_size: int = 256,
learning_rate: float = 0.001,
hidden_size: int = 32,
attention_head_size: int = 4,
dropout: float = 0.1,
)
Train TFT on panel data.
Source code in fplx/inference/tft.py
load
¶
Load a trained TFT checkpoint.
predict_gameweek
¶
predict_gameweek(
panel_df: DataFrame,
target_gw: int,
batch_size: int = 256,
) -> TFTQuantilePredictions
Predict quantiles for one target gameweek across all players.