Downloads · 30 days
0
JonusNattapong/transformer-classifier-gc1h
transformer-classifier-gc1h is a machine learning model from JonusNattapong. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for pytorch.
This repository provides a Transformer-based time series classifier trained on Gold Futures (GC=F, 1-hour timeframe) to predict short-term price direction. The model outputs Up, Flat, or Down classes which can be used…
Downloads · 30 days
0
Access
Public
Updated Oct 1, 2025
Repo size
13.2 MB
Likes
1
Public
Click a slice to open those files.
.pt4.4 MB · 82%
From the Hugging Face model README
This repository provides a Transformer-based time series classifier trained on Gold Futures (GC=F, 1-hour timeframe) to predict short-term price direction. The model outputs Up, Flat, or Down classes which can be used to generate trading signals.
The model was evaluated via a walk-forward backtest with continuous position sizing.
📊 
from huggingface_hub import hf_hub_download
import torch, torch.nn.functional as F
import numpy as np
# Download model weights
repo_id = "JonusNattapong/transformer-classifier-gc1h"
filename = "transformer_cls_gc1h.pt"
state_dict_path = hf_hub_download(repo_id=repo_id, filename=filename)
# Define model (must match training config)
model_inf = TimeSeriesTransformerCLS(
n_features=n_features,
n_classes=3,
d_model=128,
n_heads=4,
n_layers=4,
d_ff=256,
dropout=0.1
).to(device)
# Load weights
model_inf.load_state_dict(torch.load(state_dict_path, map_location=device))
model_inf.eval()
# Example Inference
example_input = scaled.iloc[-WINDOW:].values.astype(np.float32) # shape [T, F]
example_input_tensor = torch.tensor(example_input).unsqueeze(0).to(device)
with torch.no_grad():
logits = model_inf(example_input_tensor)
probabilities = F.softmax(logits, dim=1).squeeze(0).cpu().numpy()
predicted_class = int(torch.argmax(logits, dim=1).item())
print("Probabilities:", probabilities)
print("Predicted Class:", predicted_class) # 0=Down, 1=Flat, 2=Up