A comprehensive Machine Learning laboratory project implementing various time series forecasting algorithms for financial data prediction, specifically targeting the Nifty 50 stock index.
- About
- Features
- Algorithms Implemented
- Project Structure
- Prerequisites
- Installation
- Usage
- Data
- Model Performance
- Contributing
- License
- Author
QuestpondML.Lab1 is an educational and experimental platform developed by Mrugendra (Yogesh) Bhure as part of the Questpond AI/ML Cohort. This project demonstrates practical implementation of multiple machine learning algorithms for financial time series forecasting, with a focus on real-world stock market prediction using the Nifty 50 index.
The project serves as a comprehensive learning resource for:
- Financial time series analysis and forecasting
- Multiple ML algorithm comparison and evaluation
- Feature engineering for time series data
- Model evaluation using comprehensive metrics
- AutoML experimentation and automated model selection
- Fast Forest Regression - Ensemble method for non-linear pattern detection
- Singular Spectrum Analysis (SSA) - Advanced time series decomposition with confidence intervals
- Support Vector Regression (SVR) - Kernel-based regression approach
- AutoML Experimentation - Automated model discovery and optimization
- Lag Feature Engineering - Creates temporal features (6 lag periods)
- Relative Strength Index (RSI) - Technical indicator for momentum analysis
- Data Preprocessing - Custom parsing and normalization
- Train/Test Splitting - Proper temporal validation
- Logarithmic Transformation - Optional scaling for exponential patterns
- RΒ² (Coefficient of Determination)
- Mean Absolute Error (MAE)
- Mean Squared Error (MSE)
- Root Mean Squared Error (RMSE)
- Mean Absolute Percentage Error (MAPE)
- Type: Ensemble method using decision trees
- Best for: Non-linear relationships and complex patterns
- Features: 6 lag features as input, 95/5 train-test split
- Type: Time series decomposition method
- Best for: Advanced forecasting with confidence intervals
- Configuration: Window size: 12, Series length: 120
- Output: Point forecasts with upper/lower confidence bounds
- Type: Kernel-based regression
- Best for: High-dimensional feature spaces
- Features: 6 lag features + RSI, feature normalization, 6-period holdout validation
- Type: Automated model discovery
- Optimization: RΒ² metric maximization
- Runtime: Limited to 120 seconds for efficiency
QuestpondML.Lab1/
βββ π README.md # This file
βββ π LICENSE.txt # MIT License
βββ π QuestpondML.Lab1.sln # Solution file
β
βββ π QuestpondML.Lab1/ # Main project
βββ π Program.cs # Main entry point
βββ π QuestpondML.Lab1.csproj # Project configuration
β
βββ π Labs/ # ML implementations
β βββ π NiftyEstimator.cs # Core ML algorithms
β
βββ π Model/ # Data models
β βββ π HistoricalStockPrice.cs # Data structures
β
βββ π Data/ # Dataset
β βββ π Nifty 50 Historical Data.csv
β
βββ π bin/ # Build output
βββ π obj/ # Build intermediates
βββ π .vs/ # VS configuration
- .NET 8.0 SDK or higher
- Visual Studio 2022 or compatible IDE
- Windows OS (project uses Windows-specific paths)
- Git for cloning
-
Clone the repository
git clone https://github.com/anvaya/QuestpondML.Lab1.git cd QuestpondML.Lab1s -
Restore NuGet packages
dotnet restore
-
Build the project
dotnet build
| Package | Version | Purpose |
|---|---|---|
Microsoft.ML |
5.0.0 | Core ML.NET framework |
Microsoft.ML.AutoML |
0.23.0 | Automated ML capabilities |
Microsoft.ML.Mkl.Components |
5.0.0 | Intel Math Kernel Library optimizations |
-
Navigate to the project directory
cd QuestpondML.Lab1 -
Run the current experiment
dotnet run
-
Switch between algorithms (edit
Program.cs):// Currently active: SSA estimator.RunSsa(); // Uncomment to use other algorithms: // estimator.RunAutoMLExperiment(); // estimator.RunSVR(); // estimator.RunReplWithFastForrest();
var estimator = new NiftyEstimator();
estimator.RunReplWithFastForrest();var estimator = new NiftyEstimator();
estimator.RunSsa();var estimator = new NiftyEstimator();
estimator.RunSVR();var estimator = new NiftyEstimator();
estimator.RunAutoMLExperiment();- Source: Nifty 50 Historical Data
- Format: CSV (Comma-separated values)
- Columns:
Date,Price - Date Format:
dd-MM-yyyy(e.g.,01-05-2024) - Time Range: May 2024 to November 2025 (monthly data)
- Price Format: Comma thousands separator (e.g.,
22,901.35)
Date,Price
01-05-2024,22,901.35
01-06-2024,23,110.45
...
The HistoricalStockPrice model includes the following features:
- Date: DateTime object for temporal ordering
- Price: Current price (log-transformed for modeling)
- LagPrice0-5: 6 lagged price features for temporal patterns
- RSI: Relative Strength Index (14-period default, configurable)
- Date Parsing: Converts
dd-MM-yyyyformat toDateTime - Price Normalization: Removes comma separators, converts to
float - Lag Feature Creation: Generates 6 lagged price features
- RSI Calculation: Computes Relative Strength Index with configurable period (default: 6)
- Optional Log Transformation: Applies logarithmic scaling for model training
The CalculateRSI function implements the standard Relative Strength Index algorithm:
Algorithm Details:
- Default Period: 6 periods (configurable, optimized for monthly data)
- Formula:
RSI = 100 - (100 / (1 + RS))whereRS = Average Gain / Average Loss - Smoothing: Uses smoothed moving average for RSI calculation
- Log Scale Handling: Automatically converts from logarithmic price data
- Edge Cases: Handles insufficient data gracefully (RSI = 0 for initial periods)
Features:
- Configurable calculation period
- Support for log-transformed price data
- Efficient memory usage with in-place calculations
- Robust handling of edge cases (zero losses, insufficient data)
=== Model Performance Metrics ===
RΒ² Score: 0.8567
MAE: 245.32
MSE: 85,432.11
RMSE: 292.27
MAPE: 1.24%
=== SSA Forecast Results ===
Period 1 Forecast: 23,450.67
Confidence Interval: [23,100.12, 23,801.22]
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
- Follow C# coding conventions
- Add XML documentation for new methods
- Update this README for significant changes
- Ensure all NuGet packages are updated
This project is licensed under the MIT License - see the LICENSE.txt file for details.
Mrugendra (Yogesh) Bhure
- Role: Questpond AI/ML Cohort Member
- Focus: Machine Learning & Financial Time Series Analysis
- Project: QuestpondML Laboratory Experiments
π Educational Purpose: This project is part of the Questpond AI/ML Cohort training program and serves as a practical demonstration of machine learning concepts applied to financial forecasting.