Giter Club home page Giter Club logo

sp500-forecasting-xgboost's Introduction

S&P 500 Index Forecasting using XGBoost

License: MIT GitHub Stars GitHub Downloads GitHub Forks

Alt text This repository houses a Jupyter notebook showcasing the XGBoost for forecasting the S&P 500 index using time-series data.

๐Ÿ“– Table of Contents

๐Ÿ“Œ Overview

The notebook ingests historical S&P 500 Index data, preprocesses it, and then employs the XGBoost regression model to forecast the index. The model's performance is evaluated using metrics such as Root Mean Squared Error (RMSE), Mean Absolute Error (MAE), and R-squared (Coefficient of Determination).

๐Ÿ“Š Dataset

  • File Name: sp500_index.csv
  • Description: The dataset contains historical values of the S&P 500 Index. The data is cleaned by handling null values and removing rows with zero values in the 'S&P500' column. The dataset is then visualized to provide a clear view of the S&P 500 Index over time.

๐Ÿ”ง Dependencies

To run the notebook, you'll need the following libraries:

  • pandas
  • numpy
  • matplotlib
  • scikit-learn
  • xgboost

You can install these using pip:

pip install pandas numpy matplotlib scikit-learn xgboost

๐Ÿš€ Usage

  1. Clone the repository:

    git clone https://github.com/yourusername/sp500-forecasting-xgboost.git
  2. Navigate to the cloned directory and open the Jupyter notebook"

    cd sp500-forecasting-xgboost
    jupyter notebook
  3. Run the notebook: Execute the notebook cells sequentially to preprocess the data, train the XGBoost model, and evaluate its performance.

๐Ÿ“ˆ Key Findings

  • Consistent rise from 2014 to mid-2017.
  • Fluctuations and a notable decline around 2018.
  • Surge from early 2019 to 2020.
  • Sharp decline in 2020, likely indicating an economic downturn.
  • Swift recovery leading into 2022.
  • Relative stability with minor oscillations from 2022 to 2024.
  • Root Mean Squared Error (RMSE): 52.67, indicating an average deviation of approximately 52.67 points from the actual S&P 500 index values.
  • Mean Absolute Error (MAE): 21.41, signifying an average absolute error of 21.41 points in the model's predictions.
  • R-squared value: 0.97 (or 91%), suggesting that the model explains 91% of the variance in the S&P 500 index.
  • Actual vs. Predicted Analysis: The XGBoost model's predictions generally followed the actual trajectory of the S&P 500 Index.
  • While the overall trend was captured, there were specific instances where the model's predictions deviated from the actual values.

๐Ÿ’ก Contributions

Contributions to this repository are very welcome! Whether it's fixing bugs, improving the documentation, adding new features, or providing feedback, your insights can help improve this project. Here's how you can contribute:

  1. Fork the Project
  • Navigate to the main page of the repository.
  • Click on the Fork button on the top right.
  1. Create Your Feature Branch

    git checkout -b feature/AmazingFeature
  2. Commit Your Changes

    git commit -m 'Add some AmazingFeature'
  3. Push to the Branch

    git push origin feature/AmazingFeature
  4. Open a Pull Request

  • Navigate back to the main page of your forked repository.
  • Click on the "Pull requests" tab.
  • Click on the green "New pull request" button.

๐Ÿ“œ License

Distributed under the MIT License. See LICENSE for more information.

๐Ÿ‘ค Authors

๐Ÿ™Œ Acknowledgements

I would like to acknowledge and express my gratitude to the Standard and Poor's 500 (S&P 500) for being a cornerstone in the world of finance. Recognized globally as the premier financial benchmark, the S&P 500 diligently tracks the performance of 500 eminent companies listed on U.S. stock exchanges. It's noteworthy to mention that as of December 31, 2020, the index had influenced investments exceeding $5.4 trillion in assets, a testament to its significance in the financial landscape.

A special mention to the intricacies of the index: while it's named the S&P 500, it encompasses 505 stocks, factoring in multiple classes of stock from certain constituent companies, such as Alphabet's Class A (GOOGL) and Class C (GOOG).

I deeply appreciate the transparency, consistency, and dedication with which the S&P 500 operates, providing invaluable insights and benchmarks for investors and financial analysts worldwide.

sp500-forecasting-xgboost's People

Contributors

jorgesandoval avatar

Stargazers

tcosnr avatar Mauricio Lyrio avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.