GMI · TECHNOLOGY OBSERVATORY // ALL SYSTEMS NOMINAL
ENGINEERED BY LEOPARD DATA

Machine Learning in Reports

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
  • Anomaly Alerts: Highlighted unusual patterns
  • Confidence Intervals: Statistical reliability indicators
Visual Enhancements
  • Forecast Charts: Line graphs showing predicted trends
  • Confidence Bands: Visual uncertainty ranges
  • Health Score Gauges: Dashboard-style score visualizations
  • Color-Coded Alerts: Risk level indicators
Sample Excel Output with ML Features
Quarter Historical Revenue ML Forecast Confidence Health Score
Q3 2025 $89.5B - - 85/100
Q4 2025 $92.1B - - 87/100
Q1 2026 - $95.2B 85% 88/100
Q2 2026 - $98.1B 82% 89/100
Q3 2026 - $101.5B 78% 90/100
Yellow rows indicate ML.NET predictions. Confidence decreases for longer-term forecasts.
Sample Sentiment Forecasting Tab
Period Predicted Sentiment Intensity Score Confidence Risk Level Key Factors
Week 1 Bullish 📈 78/100 85% Low Strong momentum, RSI: 65
Week 2 Bullish 📈 74/100 82% Low Volume spike, positive MA
Week 3 Neutral ➡️ 45/100 78% Medium Mixed signals, volatility
Week 4 Bearish 📉 25/100 75% High Resistance level, overbought
Sentiment forecasting uses technical indicators, price patterns, and volume analysis to predict market sentiment trends.

JSON Output with ML Data

Machine Learning Data Structure

JSON reports include structured ML predictions, making the data easily consumable by other applications:

{
  "symbol": "AAPL",
  "reportDate": "2026-04-01",
  "machineLearning": {
    "forecasts": {
      "revenue": {
        "algorithm": "SSA",
        "horizon": 4,
        "predictions": [
          {
            "quarter": "Q1 2026",
            "value": 95200000000,
            "confidence": 0.85,
            "upperBound": 98100000000,
            "lowerBound": 92300000000
          },
          {
            "quarter": "Q2 2026",
            "value": 98100000000,
            "confidence": 0.82,
            "upperBound": 102500000000,
            "lowerBound": 93700000000
          }
        ]
      },
      "cashFlow": {
        "algorithm": "SSA",
        "predictions": [...],
        "trend": "increasing"
      }
    },
    "anomalies": [
      {
        "type": "VolumeSpike",
        "date": "2026-03-28",
        "severity": "Medium",
        "description": "Trading volume 3.2x above 30-day average"
      }
    ],
    "healthScore": {
      "overall": 87,
      "components": {
        "revenueGrowth": 22,
        "debtToEquity": 21,
        "cashFlow": 23,
        "profitability": 21
      },
      "risk": "Low"
    }
  }
}

ML Model Types

Forecasting Models
Singular Spectrum Analysis (SSA)
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 Spikes Critical
  • Price Volatility High
  • Ratio Outliers Medium
  • Seasonal Deviations Low

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)
Data Pipeline
Historical Data Extraction
Data Cleaning & Validation
Feature Engineering
ML Model Training
Prediction Generation
Report Integration