mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-08 14:07:44 +00:00
bf611d319f
- Introduced R² (Coefficient of Determination) metric with detailed mathematical foundation, performance profile, and usage examples. - Implemented SMAPE (Symmetric Mean Absolute Percentage Error) metric, addressing asymmetry in MAPE with symmetric error calculations. - Added unit tests for SMAPE covering various scenarios including edge cases and input validation. - Enhanced Dema class to correctly handle event publishing with isNew parameter. - Updated Quantower test project to include coverage configuration for better test reporting.
2.9 KiB
2.9 KiB
Errors
Error metrics and performance indicators for model/strategy evaluation. All error indicators accept two input series (actual and predicted values) and compute rolling error metrics over a configurable period.
Two-Input Pattern
All error indicators in this category follow a consistent dual-input API:
// Streaming mode
var mae = new Mae(period: 14);
var result = mae.Update(actualValue, predictedValue);
// Batch mode
var maeSeries = Mae.Calculate(actualSeries, predictedSeries, period: 14);
// Span mode (zero-allocation)
Mae.Batch(actualSpan, predictedSpan, outputSpan, period: 14);
Indicator Reference
| Indicator | Full Name | Description |
|---|---|---|
| HUBER | Huber Loss | Combines MSE and MAE; less sensitive to outliers |
| MAE | Mean Absolute Error | Average of absolute differences |
| MAPD | Mean Absolute Percentage Deviation | Percentage error relative to mean of actual and predicted |
| MAPE | Mean Absolute Percentage Error | Percentage error relative to actual values |
| MASE | Mean Absolute Scaled Error | Scale-free error using naive forecast as baseline |
| ME | Mean Error | Average of signed differences (bias detector) |
| MPE | Mean Percentage Error | Signed percentage error (directional bias) |
| MSE | Mean Squared Error | Average of squared differences |
| MSLE | Mean Squared Logarithmic Error | MSE on log-transformed values |
| RAE | Relative Absolute Error | Absolute error relative to mean predictor |
| RMSE | Root Mean Squared Error | Square root of MSE; same units as input |
| RMSLE | Root Mean Squared Logarithmic Error | RMSE on log-transformed values |
| RSE | Relative Squared Error | Squared error relative to mean predictor |
| RSQUARED | Coefficient of Determination | Proportion of variance explained (1 - RSE) |
| SMAPE | Symmetric Mean Absolute Percentage Error | Bounded percentage error (0-200%) |
Choosing an Error Metric
By Use Case
| Use Case | Recommended Metrics |
|---|---|
| General accuracy | MAE, RMSE |
| Outlier-robust | MAE, Huber, MASE |
| Percentage interpretation | MAPE, SMAPE, MAPD |
| Bias detection | ME, MPE |
| Scale-free comparison | MASE, RAE, RSE |
| Model quality score | R², RSE |
| Log-scale data | MSLE, RMSLE |
By Properties
| Metric | Scale | Outlier Sensitivity | Interpretability |
|---|---|---|---|
| MAE | Original units | Low | High |
| MSE | Squared units | High | Medium |
| RMSE | Original units | High | High |
| MAPE | Percentage | Medium | High |
| SMAPE | 0-200% | Medium | High |
| Huber | Original units | Low (configurable) | Medium |
| R² | 0-1 (for good models) | High | Very High |