This project harnesses the capabilities of deep learning to predict time series data using Gated Recurrent Units (GRUs). By implementing a tailored GRU architecture in TensorFlow, the model demonstrated impressive performance, achieving high accuracy in forecasting future values. This AI-driven approach not only enhances the precision of time series predictions but also opens new avenues for research in various fields, from finance to environmental monitoring, fostering innovation in predictive analytics.
Note: The project is deployed to huggingface spaces for demo purpose. The huggingface spaces may be down if not used, and it might take a couple of minutes to startup initially.
-
You can click here to check the live demo of the streamlit app.
-
Screenshots of the streamlit app are provided below.
- Once the app is loaded click on the forcast button.
- The forecast for next 15 days will be displayed in a line chart and a table.
-
Importance of Data Preprocessing: Properly preparing the dataset, including normalization and handling missing values, was crucial for improving model performance and ensuring accurate predictions.
-
Hyperparameter Tuning: Experimenting with different hyperparameters (e.g., learning rate, batch size, number of layers) significantly impacted the model's accuracy and convergence speed, highlighting the need for thorough experimentation.
-
Cross-Validation for Consistency: Implementing cross-validation was essential for assessing the model's performance across different datasets, ensuring reliability and robustness in predictions.
-
Model Evaluation and Visualization: Visualizing predictions versus actual values, as well as analyzing residuals, provided valuable insights into model performance and areas for improvement, reinforcing the importance of thorough evaluation.
-
The model achieved a high training R² value of 94%, demonstrating its effectiveness in capturing the variance in the training data.
-
With a strong validation R² of 88%, the model showed robust performance, indicating good generalization to unseen data and effective learning of underlying patterns.
-
The model maintained a solid R² of 88% in testing, further validating its reliability and consistency across different datasets in predicting future values.
- Analyzing the residual plot revealed specific areas of prediction error, providing insights into potential adjustments needed for future model improvements.
To set up the project locally, follow these steps:
git clone https://github.com/bhuvaneshprasad/TimeSeries-Forecasting-on-Stock-Market-Data
cd TimeSeries-Forecasting-on-Stock-Market-Data
- Create a virtual environment (recommended) and install the required packages:
python -m venv venv
venv\Scripts\activate # On Linux use `source venv/bin/activate`
pip install -r requirements.txt
- To get the model artifacts like datasets, scaler and model train the model using below command
python main.py
- After getting the artifacts, run streamlit app using below command
python streamlit/app.py
- To test the API route use below command
uvicorn app:app --reload
- The API endpoint will be available at https://localhost:8000/forecast
Note:
-
You can adjust the parameters in params.yaml to experiment with different configurations.
-
If you get any error check streamlit/app.py and app.py in the root directories for the correct file paths of the artifacts.