How Grade My Investments leverages ML.NET to enhance financial reports with predictive analytics, forecasting, and intelligent insights.
ML PIPELINE
rendering diagram…
flowchart TB
A[(Historical<br/>Financial Data)]:::data --> B[Data Preparation<br/>Normalize - Validate]:::svc
B --> C[Feature Engineering<br/>Time Series]:::svc
C --> D{Model<br/>Selection}:::app
D --> E[SSA Forecasting<br/>Revenue - Debt - Cash Flow]:::app
D --> F[IID Spike Detection<br/>Anomaly Alerts]:::app
D --> G[Multi-class Classification<br/>Bullish - Neutral - Bearish]:::app
D --> H[Health Score<br/>4-factor 0-100]:::app
E --> I[4-Quarter<br/>Forecast]:::svc
F --> J[Anomaly<br/>Alerts]:::svc
G --> K[Sentiment<br/>Forecast]:::svc
H --> L[Health<br/>Score]:::svc
I --> M[(Excel Report<br/>JSON Output)]:::data
J --> M
K --> M
L --> M
classDef app fill:#1f2630,stroke:#C0894E,color:#F3EFE8;
classDef svc fill:#241c14,stroke:#E2B583,color:#F3EFE8;
classDef data fill:#22201a,stroke:#C0894E,color:#EBD3AE;
classDef ext fill:#1b1f27,stroke:#5A616B,color:#C4C0B8;
classDef sec fill:#1d2733,stroke:#5cc8e0,color:#eafaff;
ML.NET pipeline: historical financial data flows through four model types to produce forecast, anomaly, health, and sentiment outputs embedded in Excel and JSON reports.
ML.NET-Powered Report Enhancement
Intelligent Reports: Grade My Investments' reports go beyond traditional data presentation by incorporating machine learning predictions, forecasts, and anomaly detection directly into Excel and JSON outputs.
Enhanced Report Features
Future Revenue Predictions: 4-quarter ahead revenue forecasts with confidence intervals
Cash Flow Projections: Free cash flow trend analysis and predictions
Financial Health Scoring: Automated 0-100 health scores based on multiple metrics
Anomaly Alerts: Automatic detection of unusual trading patterns or financial metrics
ML Integration Workflow
1
Data Preparation
Historical financial data is normalized and structured for ML processing
2
Model Training
ML.NET trains forecasting models on-the-fly for each symbol
3
Prediction Generation
Models generate forecasts with confidence intervals
4
Report Integration
Predictions are seamlessly embedded into Excel worksheets and JSON
Excel Report ML Features
Enhanced Excel Worksheets
ML.NET predictions are integrated directly into Excel reports, providing users with actionable forecasts alongside traditional financial data:
New Worksheet Sections
Revenue Forecast Tab: Quarterly predictions with charts
Health Score Summary: Financial health ratings and explanations
Sentiment Forecast Tab: Market sentiment predictions and trend analysis
Primary algorithm for revenue, debt, cash flow, and equity forecasting
Accuracy: 85-92%
Simple Trend Fallback
Fallback when SSA fails due to data constraints
Accuracy: 78-88%
Spike Detection (IID)
For anomaly detection in financial ratios
Detection rate: 95%
Multi-class Classification
For sentiment forecasting (Bullish/Neutral/Bearish)
Accuracy: 72-80%
Anomaly Detection
Detection Categories
Volume SpikesCritical
Price VolatilityHigh
Ratio OutliersMedium
Seasonal DeviationsLow
Health Scoring
Scoring Components
Revenue Growth
25%
Debt-to-Equity
25%
Cash Flow
25%
Profitability
25%
Score Interpretation
80-100: Excellent
60-79: Good
0-59: Poor
Performance Metrics
1000+
Stocks processed per minute
85%
Average forecast accuracy
95%
Anomaly detection rate
4
Quarters forecast horizon
Technical Implementation
ML.NET Integration
The ML.NET framework is integrated into both the Report Generator Alpha and PyEasy console applications through the MLForecastingService class, which implements the IMLForecastingService interface:
Key Implementation Features
Real-time Training: Models are trained on-demand for each symbol
SSA Forecasting: Singular Spectrum Analysis with simple trend fallback
Minimum Data: 4 quarters of historical data required per symbol
Memory Efficiency: Models are disposed after prediction to optimize memory
Parallel Processing: Multiple stocks can be analyzed simultaneously
Error Handling: Graceful fallback when SSA fails or insufficient data
Configurable Horizons: Forecast periods can be adjusted per use case (default: 4 quarters)