Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Time Series Forecasting Using Machine Learning and Deep Learning

A comprehensive Data Mining project that explores time series forecasting using both classical machine learning and deep learning techniques. The project focuses on predicting future stock prices from the NASDAQ-100 dataset through feature engineering, model comparison, and multi-step forecasting.

Note:
This project was originally developed in Jupyter Notebook. For easier version control and sharing on GitHub, the notebook has been exported as a Python (.py) file while preserving the original implementation.


Project Information

Item Description
Course Data Mining
University Shahid Beheshti University
Semester Spring 2026
Author Mahan Baneshi

Project Overview

The objective of this project is to investigate different approaches for financial time series forecasting and compare their predictive performance.

The project follows a complete data mining pipeline including:

  • Data preprocessing
  • Feature engineering
  • Classical machine learning models
  • Deep learning with LSTM
  • Advanced technical indicators
  • Multi-step recursive forecasting
  • Performance evaluation

Dataset

The project uses historical NASDAQ-100 market data containing stock price information such as:

  • Open
  • High
  • Low
  • Close
  • Volume

The dataset is cleaned and organized chronologically before model training.


Project Pipeline

1. Data Preprocessing

  • Load historical data
  • Handle missing values
  • Remove duplicate records
  • Convert dates to datetime format
  • Sort observations chronologically

2. Feature Engineering

Several features are generated from the raw stock prices, including:

  • Daily Return
  • Price Range
  • Moving Average (5 Days)
  • Moving Average (10 Days)
  • Rolling Volatility

3. Advanced Feature Engineering

To improve forecasting accuracy, several technical indicators are incorporated:

  • Relative Strength Index (RSI)
  • Moving Average Convergence Divergence (MACD)
  • Signal Line
  • Average True Range (ATR)
  • Bollinger Bands

These indicators provide additional information about momentum, volatility, and market trends.


4. Data Preparation

The dataset is divided while preserving chronological order:

  • 70% Training Set
  • 15% Validation Set
  • 15% Test Set

Sliding windows are then created for sequence prediction.


5. Machine Learning Models

The following regression models are implemented and compared:

  • Linear Regression
  • Random Forest Regressor
  • XGBoost Regressor
  • Support Vector Regression (SVR)

6. Deep Learning Model

An LSTM (Long Short-Term Memory) neural network is implemented for sequential forecasting.

The model includes:

  • LSTM Layer
  • Dropout Layer
  • Dense Output Layer
  • Early Stopping
  • Model Checkpointing

7. Model Evaluation

The performance of each model is evaluated using:

  • RMSE (Root Mean Squared Error)
  • MAE (Mean Absolute Error)
  • MAPE (Mean Absolute Percentage Error)
  • R² Score

Training time is also recorded for comparison.


8. Multi-Step Forecasting

The project implements recursive forecasting to predict multiple future time steps.

Forecasts are generated for a 10-day prediction horizon, allowing comparison between short-term and long-term prediction accuracy.


Technologies Used

  • Python
  • Jupyter Notebook
  • NumPy
  • Pandas
  • Matplotlib
  • Scikit-learn
  • TensorFlow / Keras
  • XGBoost

Project Structure

.
├── NASDAQ100_data.csv
├── project.py              # Converted from Jupyter Notebook
├── best_lstm_model.keras
├── best_lstm_advanced_model.keras
├── README.md
└── requirements.txt

Implemented Models

Category Models
Machine Learning Linear Regression, Random Forest, XGBoost, SVR
Deep Learning LSTM
Forecasting Recursive Multi-Step Prediction

Key Features

  • Complete time series preprocessing pipeline
  • Classical and deep learning model comparison
  • Technical indicator engineering
  • Sliding window sequence generation
  • Multi-step recursive forecasting
  • Performance comparison using multiple evaluation metrics
  • Visualization of training and forecasting results

Running the Project

Clone the repository:

git clone <repository-url>

Install the required packages (numpy - pandas - matplotlib - sickitlearn , ...0

Run the project in Jupyter Notebook (also Annaconda or vs code)


Results

The project compares all implemented models based on forecasting accuracy and computational efficiency.

Performance is evaluated using multiple regression metrics, and the best-performing models are further analyzed through recursive multi-step forecasting.


Acknowledgment

This project was developed as part of the Data Mining course at Shahid Beheshti University during the Spring 2026 semester.


Author

Mahan Baneshi


License

This repository is intended solely for educational purposes as part of the Data Mining course at Shahid Beheshti University.

About

The goal of this project is to predict prices using machine learning models, LTSM, and Transformer.

Topics

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages