A comprehensive financial data analysis and machine learning optimization project. This repository implements and compares 9 different mathematical and machine learning models to analyze, forecast, and predict stock market pricing trends using historical data.
Predicting stock market prices is a challenging time-series forecasting problem. This project processes historical data from the National Stock Exchange (NSE) to train and evaluate various predictive algorithms. By comparing advanced Deep Learning (LSTM), automated time-series forecasting (Auto-ARIMA, Prophet), and classical Machine Learning (Random Forest, SVM), this project attempts to find the most robust approach to estimate future price movements.
- Asset: Infosys (INFY)
- Exchange: NSE India (National Stock Exchange)
- Timeframe: July 1, 2015 – July 29, 2020
- Features Provided:
Date: Traded day.Open/Close: Opening and closing price of the asset.High/Low: Maximum and minimum price reached during the session.Volume: Total number of shares traded.
- Cleaning: Missing (
NaN) values detection and imputation/removal. - Date Transformation: Parsing temporal strings into standardized timestamp types (
pd.to_datetime) for robust time-series indexing. - Feature Scaling: Normalization via Scikit-Learn's
MinMaxScalerbound to(0,1)to stabilize gradient descent and proximity-based classifiers. - Data Splitting: Splitting timeline chronologically into Training Sets (historical patterns) to Validation Sets (future timeline).
The repository evaluates 9 different algorithms, split by methodology:
- Linear Regression: A baseline statistical approach for mapping feature relations directly to prices.
- LSTM (Long Short-Term Memory): Advanced Deep Learning Recurrent Neural Network (RNN) tailored for time-series anomaly and pattern persistence.
- Logistic Regression: Probabilistic trend classification.
- K-Nearest Neighbors (KNN): Regressive prediction mapping via the closest historical similarity states.
- Decision Tree: Non-linear, logical flowchart splits against data heuristics.
- Random Forest: Ensemble bagging framework using aggregated decision trees to drop variance and protect against overfitting.
- Support Vector Machines (SVM): High-dimensional mapping to separate complex financial coordinates.
Model performance and ranking comparisons are formulated against:
- RMSE (Root Mean Squared Error): Standard deviation of prediction errors. Defines standard variance for regression fits.
- Accuracy: Base evaluation metric for trend prediction states (up/down).
Follow these steps to initialize the environment:
-
Clone the repository:
git clone https://github.com/arshsaxena/StockMarketPrediction.git cd StockMarketPrediction -
Set up Virtual Environment (Recommended):
python3 -m venv .venv source .venv/bin/activate # On Windows use: .venv\Scripts\activate
-
Install Dependencies:
pip install -r requirements.txt
-
Launch Jupyter Notebook Server:
jupyter notebook
-
Begin Analysis: Open any specific model's
.ipynbfile to run cells interactively.
Note: All algorithms provided here are evaluated for academic and educational analytics purposes only and should not be deployed as independent financial trading advice.