Downloads · 30 days
0
mohan170802/stock-price-predictor-xgboost
stock-price-predictor-xgboost is a machine learning model from mohan170802. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
Author: mohan170802 Models: mohan170802/stock-price-predictor-xgboost
Downloads · 30 days
0
Access
Public
Updated May 7, 2026
Repo size
1.9 MB
Likes
1
Public
Click a slice to open those files.
.pkl1.9 MB · 50%
From the Hugging Face model README
Author: mohan170802
Models: mohan170802/stock-price-predictor-xgboost
A production-ready XGBoost ensemble trained to predict 5-day-ahead stock price movements for swing trading. Two models per ticker:
| Ticker | Sector | Description |
|---|---|---|
| SPY | Broad Market | S&P 500 ETF |
| QQQ | Tech-heavy | Nasdaq-100 ETF |
| AAPL | Technology | Apple Inc. |
| MSFT | Technology | Microsoft Corp. |
| TSLA | Automotive | Tesla Inc. |
| NVDA | Technology | NVIDIA Corp. |
| AMD | Technology | Advanced Micro Devices |
| META | Technology | Meta Platforms |
| JPM | Financials | JPMorgan Chase |
| XOM | Energy | Exxon Mobil Corp. |
| Category | Features |
|---|---|
| Lag features | Close & volume lags at 1,2,3,5,10,20 days |
| Returns | 1d, 2d, 3d, 5d, 10d, 20d returns |
| Moving averages | SMA & EMA at 5,10,20,50 windows + price ratios |
| Momentum | RSI(14), MACD, MACD signal, MACD histogram |
| Volatility | Bollinger Bands (width, position), ATR(14), rolling std dev |
| Volume | OBV, volume SMA, volume ratio |
| Candlestick | Daily range, upper/lower shadow, body size |
| Calendar | Day-of-week, month, quarter, year, month-start/end flags |
| Metric | Mean ± Std |
|---|---|
| Regression RMSE | 0.0471 ± 0.0203 |
| Regression R² | −0.0116 ± 0.0296 |
| Directional Accuracy | 0.5683 ± 0.0353 |
| Classification Accuracy | 0.4877 ± 0.0210 |
Key insight: Exact price prediction (R² ≈ 0) is extremely hard — the directional signal at ~57% beats random chance (50%) and is actionable for swing trades when combined with risk management.
| Ticker | Directional Acc | Classification Acc | RMSE |
|---|---|---|---|
| SPY | 0.614 | 0.488 | 0.0226 |
| QQQ | 0.564 | 0.506 | 0.0331 |
| AAPL | 0.569 | 0.482 | 0.0306 |
| MSFT | 0.589 | 0.490 | 0.0334 |
| TSLA | 0.543 | 0.512 | 0.0804 |
| NVDA | 0.543 | 0.476 | 0.0497 |
| AMD | 0.585 | 0.494 | 0.0544 |
| META | 0.601 | 0.482 | 0.0414 |
| JPM | 0.569 | 0.507 | 0.0304 |
| XOM | 0.568 | 0.506 | 0.0307 |
summary.json # Complete training metrics & feature list
TICKER_reg_5d.json # XGBoost regression model (log-return target)
TICKER_clf_5d.json # XGBoost classification model (direction target)
TICKER_reg_5d.pkl # Pickled Booster (convenience)
TICKER_clf_5d.pkl # Pickled Booster (convenience)
stock_predictor.py # Training & feature engineering code
inference.py # Simple inference script
README.md # This file
import xgboost as xgb
import yfinance as yf
import numpy as np
import pandas as pd
# 1. Load model from Hub
from huggingface_hub import hf_hub_download
model_path = hf_hub_download(
repo_id="mohan170802/stock-price-predictor-xgboost",
filename="SPY_reg_5d.json"
)
model = xgb.Booster()
model.load_model(model_path)
# 2. Fetch latest data & engineer features
# (see stock_predictor.py in source for full feature pipeline)
# ...
# 3. Predict
X = xgb.DMatrix(latest_features, feature_names=feature_names)
predicted_log_return = model.predict(X)[0]
predicted_price = current_price * np.exp(predicted_log_return)
git clone https://huggingface.co/mohan170802/stock-price-predictor-xgboost
cd stock-price-predictor-xgboost
python inference.py --ticker SPY
price * exp(pred).yfinanceMIT — use at your own risk for research & educational purposes.