StockForecast Neural Models

This repository contains neural network models for financial time series forecasting, part of the StockForecast AI project for CS4063 NLP Assignment 2.

Models Included

LSTM Forecaster

  • Algorithm: Long Short-Term Memory Neural Network
  • Architecture: Single LSTM layer with Dense output
  • Lookback: 10 time steps
  • Performance: RMSE=1.89, MAE=1.45, MAPE=1.42%

Transformer Forecaster

  • Algorithm: Transformer with multi-head attention
  • Architecture: d_model=32, num_heads=2, ff_dim=64
  • Lookback: 10 time steps
  • Performance: RMSE=1.76, MAE=1.38, MAPE=1.35%

Usage

import tensorflow as tf
from huggingface_hub import snapshot_download, hf_hub_download
import joblib

# Method 1: Download complete forecaster objects (Recommended)
lstm_forecaster_path = hf_hub_download(repo_id="usman-tech-ali/stockforecast-neural-models", filename="lstm_forecaster.pkl")
transformer_forecaster_path = hf_hub_download(repo_id="usman-tech-ali/stockforecast-neural-models", filename="transformer_forecaster.pkl")

# Load complete forecasters
lstm_forecaster = joblib.load(lstm_forecaster_path)
transformer_forecaster = joblib.load(transformer_forecaster_path)

# Make predictions
lstm_predictions = lstm_forecaster.predict(steps=5)
transformer_predictions = transformer_forecaster.predict(steps=5)

# Method 2: Download individual model files
repo_path = snapshot_download(repo_id="usman-tech-ali/stockforecast-neural-models")

# Load individual TensorFlow models
lstm_model = tf.keras.models.load_model(f"{repo_path}/lstm_model")
transformer_model = tf.keras.models.load_model(f"{repo_path}/transformer_model")

# Load scalers if available
try:
    lstm_scaler = joblib.load(f"{repo_path}/lstm_model/scaler.pkl")
    transformer_scaler = joblib.load(f"{repo_path}/transformer_model/scaler.pkl")
except FileNotFoundError:
    print("Scalers not found - models may handle scaling internally")

Requirements

  • tensorflow>=2.13.0
  • numpy>=1.24.3
  • pandas>=2.0.3
  • scikit-learn>=1.3.0

Citation

@software{stockforecast_ai_2025,
  title={StockForecast AI: Complete Financial Forecasting Application},
  author={Usman Ali},
  year={2025},
  url={https://github.com/usman-tech-ali/stock-forecast-app}
}
Downloads last month
19
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support