Spaces:
No application file
No application file
| model_name: "Stock Price Predictor (XGBoost)" | |
| version: "1.0" | |
| model_type: "XGBoost Regressor" | |
| description: | | |
| This model predicts future stock prices based on historical data. | |
| It is trained on Google stock price data (2020-2025) and forecasts | |
| the Adjusted Closing Price (`Adj Close`). | |
| The model uses various stock indicators (Open, Close, High, Low, Volume) | |
| and time-based features (Year, Day, Month, Weekday) with cyclic encoding. | |
| **Ideal Use Case**: Time-series forecasting for stock prices. | |
| license: "MIT" | |
| dataset: | |
| name: "Google Stock Price Data (2020-2025)" | |
| source: "Kaggle - https://www.kaggle.com/datasets/mzohaibzeeshan/google-stock-price-data-2020-2025-googl" | |
| architecture: | |
| framework: "XGBoost" | |
| encoding: "Sin-Cos Encoding for Month/Weekday, One-Hot Encoding for categorical data" | |
| metrics: | |
| MAE: 0.212 | |
| RMSE: 0.357 | |
| R2_Score: 0.9998 | |
| deployment: | |
| huggingface: "https://huggingface.co/spaces/your_username/google-stock-predictor" | |
| github: "https://github.com/your_username/google-stock-predictor" | |
| api: "FastAPI/Gradio" | |
| usage: | |
| installation: | | |
| ```python | |
| # Install dependencies | |
| !pip install xgboost pandas numpy joblib transformers torch | |
| ``` | |
| use_pipeline: | | |
| ```python | |
| from transformers import pipeline | |
| import joblib | |
| import pandas as pd | |
| import numpy as np | |
| # Load the model | |
| model = joblib.load("xgboost_stock_model.pkl") | |
| # Define a function to use it as a pipeline | |
| def predict_stock(features): | |
| data = pd.DataFrame([features]) | |
| prediction = model.predict(data)[0] | |
| return f"π Predicted Adj Close Price: {prediction:.2f}" | |
| # Example input | |
| messages = { | |
| "Close": 200.5, "High": 201.2, "Low": 199.8, "Open": 200.0, "Volume": 1500000, | |
| "Year": 2025, "Day": 1, "Weekday_sin": 0.0, "Weekday_cos": 1.0, "Month_sin": 0.5, "Month_cos": 0.866 | |
| } | |
| prediction = predict_stock(messages) | |
| print(prediction) | |
| ``` | |
| load_model_torch: | | |
| ```python | |
| import torch | |
| import joblib | |
| model = joblib.load("xgboost_stock_model.pkl") | |
| def predict_stock_price(features): | |
| features = torch.tensor(features, dtype=torch.float32) | |
| prediction = model.predict(features.numpy().reshape(1, -1)) | |
| return prediction[0] | |
| sample_input = [200.5, 201.2, 199.8, 200.0, 1500000, 2025, 1, 0.0, 1.0, 0.5, 0.866] | |
| predicted_price = predict_stock_price(sample_input) | |
| print(f"π Predicted Stock Price: {predicted_price}") | |
| ``` | |
| --- | |