mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-18 02:28:05 +00:00
Refactor documentation for various filters and indicators to enhance clarity and consistency
- Updated Bessel, Bilateral, Blma, Butter, Conv, Ema, Kama, LSMA, MAMA, MGDI, SSF, USF, ATR, ADL, and ADOSC documentation to use bullet points for key concepts and features. - Added a new Qodana configuration file for code analysis. - Removed coverage configuration from Quantower.Tests.csproj to streamline testing setup.
This commit is contained in:
@@ -21,7 +21,7 @@ Mae.Batch(actualSpan, predictedSpan, outputSpan, period: 14);
|
||||
## Indicator Reference
|
||||
|
||||
| Indicator | Full Name | Description |
|
||||
|:----------|:----------|:------------|
|
||||
| ------ | ------ | ------ |
|
||||
| [HUBER](huber/Huber.md) | Huber Loss | Combines MSE and MAE; less sensitive to outliers |
|
||||
| [MAE](mae/Mae.md) | Mean Absolute Error | Average of absolute differences |
|
||||
| [MAPD](mapd/Mapd.md) | Mean Absolute Percentage Deviation | Percentage error relative to mean of actual and predicted |
|
||||
@@ -43,7 +43,7 @@ Mae.Batch(actualSpan, predictedSpan, outputSpan, period: 14);
|
||||
### By Use Case
|
||||
|
||||
| Use Case | Recommended Metrics |
|
||||
|:---------|:--------------------|
|
||||
| ------ | ------ |
|
||||
| General accuracy | MAE, RMSE |
|
||||
| Outlier-robust | MAE, Huber, MASE |
|
||||
| Percentage interpretation | MAPE, SMAPE, MAPD |
|
||||
@@ -55,7 +55,7 @@ Mae.Batch(actualSpan, predictedSpan, outputSpan, period: 14);
|
||||
### By Properties
|
||||
|
||||
| Metric | Scale | Outlier Sensitivity | Interpretability |
|
||||
|:-------|:------|:--------------------|:-----------------|
|
||||
| ------ | ------ | ------ | ------ |
|
||||
| MAE | Original units | Low | High |
|
||||
| MSE | Squared units | High | Medium |
|
||||
| RMSE | Original units | High | High |
|
||||
|
||||
+17
-17
@@ -12,17 +12,17 @@ Introduced by Peter J. Huber in 1964 as part of robust statistics, Huber Loss wa
|
||||
|
||||
Huber Loss uses a threshold parameter (delta) to switch between quadratic and linear behavior:
|
||||
|
||||
- **Small errors (|e| ≤ δ)**: Quadratic penalty, like MSE
|
||||
- **Large errors (|e| > δ)**: Linear penalty, like MAE
|
||||
* **Small errors (|e| ≤ δ)**: Quadratic penalty, like MSE
|
||||
* **Large errors (|e| > δ)**: Linear penalty, like MAE
|
||||
|
||||
This makes it differentiable everywhere (unlike MAE) while being robust to outliers (unlike MSE).
|
||||
|
||||
### Properties
|
||||
|
||||
- **Non-negative**: Huber ≥ 0, with 0 indicating perfect prediction
|
||||
- **Differentiable**: Smooth at the transition point (unlike MAE)
|
||||
- **Robust**: Less sensitive to outliers than MSE
|
||||
- **Configurable**: Delta controls the transition between quadratic and linear
|
||||
* **Non-negative**: Huber ≥ 0, with 0 indicating perfect prediction
|
||||
* **Differentiable**: Smooth at the transition point (unlike MAE)
|
||||
* **Robust**: Less sensitive to outliers than MSE
|
||||
* **Configurable**: Delta controls the transition between quadratic and linear
|
||||
|
||||
## Mathematical Foundation
|
||||
|
||||
@@ -34,9 +34,9 @@ $$L_{\delta}(e) = \begin{cases} \frac{1}{2}e^2 & \text{if } |e| \leq \delta \\ \
|
||||
|
||||
Where:
|
||||
|
||||
- $y$ = actual value
|
||||
- $\hat{y}$ = predicted value
|
||||
- $\delta$ = threshold parameter (default: 1.345)
|
||||
* $y$ = actual value
|
||||
* $\hat{y}$ = predicted value
|
||||
* $\delta$ = threshold parameter (default: 1.345)
|
||||
|
||||
### 2. Mean Huber Loss
|
||||
|
||||
@@ -137,14 +137,14 @@ huber.Update(110, 100); // Returns ~12.546
|
||||
|
||||
## Edge Cases
|
||||
|
||||
- **Identical Values**: Returns 0 when actual equals predicted
|
||||
- **NaN Handling**: Uses last valid value substitution
|
||||
- **Single Input**: Not supported (requires two series)
|
||||
- **Period = 1**: Returns current Huber loss
|
||||
- **Error at delta**: Uses quadratic formula (continuous transition)
|
||||
* **Identical Values**: Returns 0 when actual equals predicted
|
||||
* **NaN Handling**: Uses last valid value substitution
|
||||
* **Single Input**: Not supported (requires two series)
|
||||
* **Period = 1**: Returns current Huber loss
|
||||
* **Error at delta**: Uses quadratic formula (continuous transition)
|
||||
|
||||
## Related Indicators
|
||||
|
||||
- [MAE](../mae/Mae.md) - Mean Absolute Error (linear everywhere)
|
||||
- [MSE](../mse/Mse.md) - Mean Squared Error (quadratic everywhere)
|
||||
- [RMSE](../rmse/Rmse.md) - Root Mean Squared Error
|
||||
* [MAE](../mae/Mae.md) - Mean Absolute Error (linear everywhere)
|
||||
* [MSE](../mse/Mse.md) - Mean Squared Error (quadratic everywhere)
|
||||
* [RMSE](../rmse/Rmse.md) - Root Mean Squared Error
|
||||
|
||||
@@ -14,10 +14,10 @@ The function `log(cosh(x))` has remarkable properties: for small x, it approxima
|
||||
|
||||
### Properties
|
||||
|
||||
- **Smooth everywhere**: Infinitely differentiable
|
||||
- **Non-negative**: Always ≥ 0, with 0 for perfect prediction
|
||||
- **Robust**: Large errors grow linearly, not quadratically
|
||||
- **Convex**: Guarantees a unique minimum for optimization
|
||||
* **Smooth everywhere**: Infinitely differentiable
|
||||
* **Non-negative**: Always ≥ 0, with 0 for perfect prediction
|
||||
* **Robust**: Large errors grow linearly, not quadratically
|
||||
* **Convex**: Guarantees a unique minimum for optimization
|
||||
|
||||
## Mathematical Foundation
|
||||
|
||||
@@ -28,9 +28,9 @@ For each observation, compute:
|
||||
$$e_i = \log(\cosh(y_i - \hat{y}_i))$$
|
||||
|
||||
Where:
|
||||
- $y_i$ = actual value
|
||||
- $\hat{y}_i$ = predicted value
|
||||
- $\cosh(x) = \frac{e^x + e^{-x}}{2}$
|
||||
* $y_i$ = actual value
|
||||
* $\hat{y}_i$ = predicted value
|
||||
* $\cosh(x) = \frac{e^x + e^{-x}}{2}$
|
||||
|
||||
### 2. Approximations
|
||||
|
||||
@@ -131,15 +131,15 @@ For large errors, Log-Cosh grows approximately linearly (like L1), avoiding the
|
||||
|
||||
## Edge Cases
|
||||
|
||||
- **Perfect Predictions**: Returns exactly 0 (log(cosh(0)) = log(1) = 0)
|
||||
- **NaN Handling**: Uses last valid value substitution
|
||||
- **Single Input**: Not supported (requires two series)
|
||||
- **Period = 1**: Returns current log-cosh error
|
||||
- **Large Errors**: Numerically stable via cosh implementation
|
||||
* **Perfect Predictions**: Returns exactly 0 (log(cosh(0)) = log(1) = 0)
|
||||
* **NaN Handling**: Uses last valid value substitution
|
||||
* **Single Input**: Not supported (requires two series)
|
||||
* **Period = 1**: Returns current log-cosh error
|
||||
* **Large Errors**: Numerically stable via cosh implementation
|
||||
|
||||
## Related Indicators
|
||||
|
||||
- [MAE](../mae/Mae.md) - Mean Absolute Error (pure L1)
|
||||
- [MSE](../mse/Mse.md) - Mean Squared Error (pure L2)
|
||||
- [Huber](../huber/Huber.md) - Huber Loss (piecewise L1/L2)
|
||||
- [PseudoHuber](../pseudohuber/PseudoHuber.md) - Smooth Huber approximation
|
||||
* [MAE](../mae/Mae.md) - Mean Absolute Error (pure L1)
|
||||
* [MSE](../mse/Mse.md) - Mean Squared Error (pure L2)
|
||||
* [Huber](../huber/Huber.md) - Huber Loss (piecewise L1/L2)
|
||||
* [PseudoHuber](../pseudohuber/PseudoHuber.md) - Smooth Huber approximation
|
||||
|
||||
+16
-16
@@ -14,10 +14,10 @@ MAAPE applies `arctan(|error/actual|)` to each error before averaging. The arcta
|
||||
|
||||
### Properties
|
||||
|
||||
- **Bounded**: Always between 0 and π/2 (≈ 1.571)
|
||||
- **Scale-independent**: Percentage-based like MAPE
|
||||
- **Smooth compression**: Large errors are dampened, not truncated
|
||||
- **Zero-safe**: Handles near-zero actuals gracefully
|
||||
* **Bounded**: Always between 0 and π/2 (≈ 1.571)
|
||||
* **Scale-independent**: Percentage-based like MAPE
|
||||
* **Smooth compression**: Large errors are dampened, not truncated
|
||||
* **Zero-safe**: Handles near-zero actuals gracefully
|
||||
|
||||
## Mathematical Foundation
|
||||
|
||||
@@ -28,8 +28,8 @@ For each observation, compute:
|
||||
$$e_i = \arctan\left(\frac{|y_i - \hat{y}_i|}{|y_i|}\right)$$
|
||||
|
||||
Where:
|
||||
- $y_i$ = actual value
|
||||
- $\hat{y}_i$ = predicted value
|
||||
* $y_i$ = actual value
|
||||
* $\hat{y}_i$ = predicted value
|
||||
|
||||
### 2. Mean Calculation
|
||||
|
||||
@@ -43,8 +43,8 @@ The function is bounded:
|
||||
|
||||
$$0 \leq MAAPE \leq \frac{\pi}{2}$$
|
||||
|
||||
- When error = 0: arctan(0) = 0
|
||||
- When error → ∞: arctan(∞) → π/2
|
||||
* When error = 0: arctan(0) = 0
|
||||
* When error → ∞: arctan(∞) → π/2
|
||||
|
||||
### 4. Running Update (O(1))
|
||||
|
||||
@@ -130,14 +130,14 @@ The arctangent compression means that the difference between 100% and 1000% erro
|
||||
|
||||
## Edge Cases
|
||||
|
||||
- **Zero Actual Values**: Uses arctan(∞) = π/2 (maximum bounded error)
|
||||
- **NaN Handling**: Uses last valid value substitution
|
||||
- **Single Input**: Not supported (requires two series)
|
||||
- **Period = 1**: Returns current arctangent percentage error
|
||||
- **Perfect Predictions**: Returns exactly 0
|
||||
* **Zero Actual Values**: Uses arctan(∞) = π/2 (maximum bounded error)
|
||||
* **NaN Handling**: Uses last valid value substitution
|
||||
* **Single Input**: Not supported (requires two series)
|
||||
* **Period = 1**: Returns current arctangent percentage error
|
||||
* **Perfect Predictions**: Returns exactly 0
|
||||
|
||||
## Related Indicators
|
||||
|
||||
- [MAPE](../mape/Mape.md) - Mean Absolute Percentage Error (unbounded)
|
||||
- [SMAPE](../smape/Smape.md) - Symmetric MAPE (different bounding approach)
|
||||
- [LogCosh](../logcosh/LogCosh.md) - Log-Cosh Loss (similar compression philosophy)
|
||||
* [MAPE](../mape/Mape.md) - Mean Absolute Percentage Error (unbounded)
|
||||
* [SMAPE](../smape/Smape.md) - Symmetric MAPE (different bounding approach)
|
||||
* [LogCosh](../logcosh/LogCosh.md) - Log-Cosh Loss (similar compression philosophy)
|
||||
|
||||
+13
-13
@@ -14,10 +14,10 @@ MAE treats all errors equally, making it more robust to outliers compared to squ
|
||||
|
||||
### Properties
|
||||
|
||||
- **Non-negative**: MAE ≥ 0, with 0 indicating perfect prediction
|
||||
- **Same units**: Unlike MSE, MAE is in the same units as the original data
|
||||
- **Linear sensitivity**: Each unit of error contributes equally to the final metric
|
||||
- **Robust**: Less sensitive to outliers than squared-error metrics
|
||||
* **Non-negative**: MAE ≥ 0, with 0 indicating perfect prediction
|
||||
* **Same units**: Unlike MSE, MAE is in the same units as the original data
|
||||
* **Linear sensitivity**: Each unit of error contributes equally to the final metric
|
||||
* **Robust**: Less sensitive to outliers than squared-error metrics
|
||||
|
||||
## Mathematical Foundation
|
||||
|
||||
@@ -28,8 +28,8 @@ For each observation, calculate the absolute difference between actual and predi
|
||||
$$e_i = |y_i - \hat{y}_i|$$
|
||||
|
||||
Where:
|
||||
- $y_i$ = actual value
|
||||
- $\hat{y}_i$ = predicted value
|
||||
* $y_i$ = actual value
|
||||
* $\hat{y}_i$ = predicted value
|
||||
|
||||
### 2. Mean Calculation
|
||||
|
||||
@@ -113,13 +113,13 @@ Mae.Batch(actualSpan, predictedSpan, outputSpan, period: 20);
|
||||
|
||||
## Edge Cases
|
||||
|
||||
- **Identical Values**: Returns 0 when actual equals predicted
|
||||
- **NaN Handling**: Uses last valid value substitution
|
||||
- **Single Input**: Not supported (requires two series)
|
||||
- **Period = 1**: Returns current absolute error
|
||||
* **Identical Values**: Returns 0 when actual equals predicted
|
||||
* **NaN Handling**: Uses last valid value substitution
|
||||
* **Single Input**: Not supported (requires two series)
|
||||
* **Period = 1**: Returns current absolute error
|
||||
|
||||
## Related Indicators
|
||||
|
||||
- [MSE](../mse/Mse.md) - Mean Squared Error
|
||||
- [RMSE](../rmse/Rmse.md) - Root Mean Squared Error
|
||||
- [MAPE](../mape/Mape.md) - Mean Absolute Percentage Error
|
||||
* [MSE](../mse/Mse.md) - Mean Squared Error
|
||||
* [RMSE](../rmse/Rmse.md) - Root Mean Squared Error
|
||||
* [MAPE](../mape/Mape.md) - Mean Absolute Percentage Error
|
||||
|
||||
+16
-16
@@ -14,11 +14,11 @@ MAPD divides each absolute error by the predicted value instead of the actual va
|
||||
|
||||
### Properties
|
||||
|
||||
- **Scale-independent**: Expressed as percentage
|
||||
- **Asymmetric**: Penalizes under-prediction more than over-prediction
|
||||
- **Undefined at zero**: Cannot compute when predicted value is zero
|
||||
- **Non-negative**: MAPD ≥ 0, with 0 indicating perfect prediction
|
||||
- **Opposite bias to MAPE**: Favors over-prediction
|
||||
* **Scale-independent**: Expressed as percentage
|
||||
* **Asymmetric**: Penalizes under-prediction more than over-prediction
|
||||
* **Undefined at zero**: Cannot compute when predicted value is zero
|
||||
* **Non-negative**: MAPD ≥ 0, with 0 indicating perfect prediction
|
||||
* **Opposite bias to MAPE**: Favors over-prediction
|
||||
|
||||
## Mathematical Foundation
|
||||
|
||||
@@ -30,8 +30,8 @@ $$APD_i = 100 \times \left| \frac{y_i - \hat{y}_i}{\hat{y}_i} \right|$$
|
||||
|
||||
Where:
|
||||
|
||||
- $y_i$ = actual value
|
||||
- $\hat{y}_i$ = predicted value
|
||||
* $y_i$ = actual value
|
||||
* $\hat{y}_i$ = predicted value
|
||||
|
||||
### 2. Mean Calculation
|
||||
|
||||
@@ -127,15 +127,15 @@ mapd.Update(200, 100); // |200-100|/100 = 100%
|
||||
|
||||
## Edge Cases
|
||||
|
||||
- **Identical Values**: Returns 0% when actual equals predicted
|
||||
- **Zero Predicted**: Uses epsilon (1e-10) to avoid division by zero
|
||||
- **NaN Handling**: Uses last valid value substitution
|
||||
- **Single Input**: Not supported (requires two series)
|
||||
- **Period = 1**: Returns current percentage deviation
|
||||
* **Identical Values**: Returns 0% when actual equals predicted
|
||||
* **Zero Predicted**: Uses epsilon (1e-10) to avoid division by zero
|
||||
* **NaN Handling**: Uses last valid value substitution
|
||||
* **Single Input**: Not supported (requires two series)
|
||||
* **Period = 1**: Returns current percentage deviation
|
||||
|
||||
## Related Indicators
|
||||
|
||||
- [MAPE](../mape/Mape.md) - Mean Absolute Percentage Error (divides by actual)
|
||||
- [SMAPE](../smape/Smape.md) - Symmetric Mean Absolute Percentage Error
|
||||
- [MPE](../mpe/Mpe.md) - Mean Percentage Error (signed)
|
||||
- [MAE](../mae/Mae.md) - Mean Absolute Error (same units)
|
||||
* [MAPE](../mape/Mape.md) - Mean Absolute Percentage Error (divides by actual)
|
||||
* [SMAPE](../smape/Smape.md) - Symmetric Mean Absolute Percentage Error
|
||||
* [MPE](../mpe/Mpe.md) - Mean Percentage Error (signed)
|
||||
* [MAE](../mae/Mae.md) - Mean Absolute Error (same units)
|
||||
|
||||
+16
-16
@@ -14,11 +14,11 @@ MAPE divides each absolute error by the actual value, converting errors to perce
|
||||
|
||||
### Properties
|
||||
|
||||
- **Scale-independent**: Expressed as percentage
|
||||
- **Asymmetric**: Penalizes over-prediction more than under-prediction
|
||||
- **Undefined at zero**: Cannot compute when actual value is zero
|
||||
- **Non-negative**: MAPE ≥ 0, with 0 indicating perfect prediction
|
||||
- **No upper bound**: Can exceed 100% for large errors
|
||||
* **Scale-independent**: Expressed as percentage
|
||||
* **Asymmetric**: Penalizes over-prediction more than under-prediction
|
||||
* **Undefined at zero**: Cannot compute when actual value is zero
|
||||
* **Non-negative**: MAPE ≥ 0, with 0 indicating perfect prediction
|
||||
* **No upper bound**: Can exceed 100% for large errors
|
||||
|
||||
## Mathematical Foundation
|
||||
|
||||
@@ -30,8 +30,8 @@ $$APE_i = 100 \times \left| \frac{y_i - \hat{y}_i}{y_i} \right|$$
|
||||
|
||||
Where:
|
||||
|
||||
- $y_i$ = actual value
|
||||
- $\hat{y}_i$ = predicted value
|
||||
* $y_i$ = actual value
|
||||
* $\hat{y}_i$ = predicted value
|
||||
|
||||
### 2. Mean Calculation
|
||||
|
||||
@@ -143,15 +143,15 @@ Same absolute error (50), but over-prediction shows higher MAPE.
|
||||
|
||||
## Edge Cases
|
||||
|
||||
- **Identical Values**: Returns 0% when actual equals predicted
|
||||
- **Zero Actual**: Uses epsilon (1e-10) to avoid division by zero
|
||||
- **NaN Handling**: Uses last valid value substitution
|
||||
- **Single Input**: Not supported (requires two series)
|
||||
- **Period = 1**: Returns current percentage error
|
||||
* **Identical Values**: Returns 0% when actual equals predicted
|
||||
* **Zero Actual**: Uses epsilon (1e-10) to avoid division by zero
|
||||
* **NaN Handling**: Uses last valid value substitution
|
||||
* **Single Input**: Not supported (requires two series)
|
||||
* **Period = 1**: Returns current percentage error
|
||||
|
||||
## Related Indicators
|
||||
|
||||
- [MAPD](../mapd/Mapd.md) - Mean Absolute Percentage Deviation (divides by predicted)
|
||||
- [SMAPE](../smape/Smape.md) - Symmetric Mean Absolute Percentage Error
|
||||
- [MPE](../mpe/Mpe.md) - Mean Percentage Error (signed)
|
||||
- [MAE](../mae/Mae.md) - Mean Absolute Error (same units)
|
||||
* [MAPD](../mapd/Mapd.md) - Mean Absolute Percentage Deviation (divides by predicted)
|
||||
* [SMAPE](../smape/Smape.md) - Symmetric Mean Absolute Percentage Error
|
||||
* [MPE](../mpe/Mpe.md) - Mean Percentage Error (signed)
|
||||
* [MAE](../mae/Mae.md) - Mean Absolute Error (same units)
|
||||
|
||||
@@ -10,8 +10,8 @@ MASE computes a ratio: the mean absolute error of your predictions divided by th
|
||||
|
||||
### Interpretation Guide
|
||||
|
||||
| MASE Value | Interpretation |
|
||||
|:-------------|:---------------|
|
||||
| MASE Value | Interpretation |
|
||||
| ---------- | -------------- |
|
||||
| **MASE < 1** | Forecast is better than naive (good) |
|
||||
| **MASE = 1** | Forecast equals naive performance |
|
||||
| **MASE > 1** | Forecast is worse than naive (bad) |
|
||||
@@ -42,7 +42,7 @@ $$\text{MASE} = \frac{\text{MAE}}{\text{Scale}}$$
|
||||
## Performance Profile
|
||||
|
||||
| Metric | Score | Notes |
|
||||
|:-------|:------|:------|
|
||||
| ------ | ----- | ----- |
|
||||
| **Throughput** | ~35 ns/bar | Dual running sums for error and scale |
|
||||
| **Allocations** | 0 | Zero-allocation implementation |
|
||||
| **Complexity** | O(1) | Constant time per update |
|
||||
@@ -85,7 +85,7 @@ Mase.Batch(actualSpan, predictedSpan, outputSpan, 14);
|
||||
## Comparison with Other Error Metrics
|
||||
|
||||
| Metric | Scale-Independent | Handles Zero | Symmetric | Interpretable |
|
||||
|:-------|:------------------|:-------------|:----------|:--------------|
|
||||
| ------ | ----------------- | ------------ | --------- | ------------- |
|
||||
| **MASE** | ✅ | ✅ | ✅ | ✅ (vs naive) |
|
||||
| **MAPE** | ✅ | ❌ | ❌ | ✅ (% error) |
|
||||
| **SMAPE** | ✅ | ⚠️ | ✅ | ⚠️ (bounded %) |
|
||||
@@ -94,7 +94,7 @@ Mase.Batch(actualSpan, predictedSpan, outputSpan, 14);
|
||||
|
||||
MASE is particularly valuable when:
|
||||
|
||||
- Comparing forecasts across different series
|
||||
- Evaluating against a natural baseline (naive forecast)
|
||||
- Working with data that includes zeros
|
||||
- Needing symmetric treatment of over/under predictions
|
||||
* Comparing forecasts across different series
|
||||
* Evaluating against a natural baseline (naive forecast)
|
||||
* Working with data that includes zeros
|
||||
* Needing symmetric treatment of over/under predictions
|
||||
|
||||
+14
-14
@@ -14,10 +14,10 @@ MdAE maintains a sorted view of errors through a specialized ring buffer. When n
|
||||
|
||||
### Properties
|
||||
|
||||
- **Outlier-robust**: Unaffected by extreme values
|
||||
- **Non-negative**: MdAE ≥ 0, with 0 indicating perfect prediction
|
||||
- **Same units**: Results are in the same units as the original data
|
||||
- **Stable**: Small changes in data produce small changes in output
|
||||
* **Outlier-robust**: Unaffected by extreme values
|
||||
* **Non-negative**: MdAE ≥ 0, with 0 indicating perfect prediction
|
||||
* **Same units**: Results are in the same units as the original data
|
||||
* **Stable**: Small changes in data produce small changes in output
|
||||
|
||||
## Mathematical Foundation
|
||||
|
||||
@@ -28,8 +28,8 @@ For each observation, calculate the absolute difference:
|
||||
$$e_i = |y_i - \hat{y}_i|$$
|
||||
|
||||
Where:
|
||||
- $y_i$ = actual value
|
||||
- $\hat{y}_i$ = predicted value
|
||||
* $y_i$ = actual value
|
||||
* $\hat{y}_i$ = predicted value
|
||||
|
||||
### 2. Median Calculation
|
||||
|
||||
@@ -119,14 +119,14 @@ Mdae.Batch(actualSpan, predictedSpan, outputSpan, period: 20);
|
||||
|
||||
## Edge Cases
|
||||
|
||||
- **Identical Values**: Returns 0 when actual equals predicted
|
||||
- **NaN Handling**: Uses last valid value substitution
|
||||
- **Single Input**: Not supported (requires two series)
|
||||
- **Period = 1**: Returns current absolute error
|
||||
- **All Same Errors**: Returns that error value
|
||||
* **Identical Values**: Returns 0 when actual equals predicted
|
||||
* **NaN Handling**: Uses last valid value substitution
|
||||
* **Single Input**: Not supported (requires two series)
|
||||
* **Period = 1**: Returns current absolute error
|
||||
* **All Same Errors**: Returns that error value
|
||||
|
||||
## Related Indicators
|
||||
|
||||
- [MAE](../mae/Mae.md) - Mean Absolute Error (uses mean)
|
||||
- [MdAPE](../mdape/Mdape.md) - Median Absolute Percentage Error
|
||||
- [Huber](../huber/Huber.md) - Huber Loss (robust but differentiable)
|
||||
* [MAE](../mae/Mae.md) - Mean Absolute Error (uses mean)
|
||||
* [MdAPE](../mdape/Mdape.md) - Median Absolute Percentage Error
|
||||
* [Huber](../huber/Huber.md) - Huber Loss (robust but differentiable)
|
||||
|
||||
+14
-14
@@ -14,10 +14,10 @@ MdAPE first normalizes each error as a percentage of the actual value, then find
|
||||
|
||||
### Properties
|
||||
|
||||
- **Scale-independent**: Comparable across different data magnitudes
|
||||
- **Outlier-robust**: Extreme errors don't skew results
|
||||
- **Percentage-based**: Results are interpretable as "typical % error"
|
||||
- **Non-negative**: MdAPE ≥ 0, with 0 indicating perfect prediction
|
||||
* **Scale-independent**: Comparable across different data magnitudes
|
||||
* **Outlier-robust**: Extreme errors don't skew results
|
||||
* **Percentage-based**: Results are interpretable as "typical % error"
|
||||
* **Non-negative**: MdAPE ≥ 0, with 0 indicating perfect prediction
|
||||
|
||||
## Mathematical Foundation
|
||||
|
||||
@@ -28,8 +28,8 @@ For each observation, calculate the percentage error:
|
||||
$$e_i = \frac{|y_i - \hat{y}_i|}{|y_i|} \times 100$$
|
||||
|
||||
Where:
|
||||
- $y_i$ = actual value
|
||||
- $\hat{y}_i$ = predicted value
|
||||
* $y_i$ = actual value
|
||||
* $\hat{y}_i$ = predicted value
|
||||
|
||||
### 2. Median Calculation
|
||||
|
||||
@@ -116,14 +116,14 @@ Mdape.Batch(actualSpan, predictedSpan, outputSpan, period: 20);
|
||||
|
||||
## Edge Cases
|
||||
|
||||
- **Zero Actual Values**: Substitutes with small epsilon to avoid division by zero
|
||||
- **NaN Handling**: Uses last valid value substitution
|
||||
- **Single Input**: Not supported (requires two series)
|
||||
- **Period = 1**: Returns current absolute percentage error
|
||||
- **All Perfect**: Returns 0%
|
||||
* **Zero Actual Values**: Substitutes with small epsilon to avoid division by zero
|
||||
* **NaN Handling**: Uses last valid value substitution
|
||||
* **Single Input**: Not supported (requires two series)
|
||||
* **Period = 1**: Returns current absolute percentage error
|
||||
* **All Perfect**: Returns 0%
|
||||
|
||||
## Related Indicators
|
||||
|
||||
- [MAPE](../mape/Mape.md) - Mean Absolute Percentage Error (uses mean)
|
||||
- [MdAE](../mdae/Mdae.md) - Median Absolute Error (non-percentage)
|
||||
- [SMAPE](../smape/Smape.md) - Symmetric MAPE (different normalization)
|
||||
* [MAPE](../mape/Mape.md) - Mean Absolute Percentage Error (uses mean)
|
||||
* [MdAE](../mdae/Mdae.md) - Median Absolute Error (non-percentage)
|
||||
* [SMAPE](../smape/Smape.md) - Symmetric MAPE (different normalization)
|
||||
|
||||
+16
-16
@@ -14,12 +14,12 @@ ME preserves the sign of errors, allowing positive and negative errors to cancel
|
||||
|
||||
### Properties
|
||||
|
||||
- **Can be negative**: ME can be positive, negative, or zero
|
||||
- **Positive ME**: Model under-predicts (actual > predicted on average)
|
||||
- **Negative ME**: Model over-predicts (actual < predicted on average)
|
||||
- **Zero ME**: No systematic bias (but not necessarily accurate)
|
||||
- **Same units**: ME is in the same units as the original data
|
||||
- **Cancellation**: Errors can cancel out, hiding large individual errors
|
||||
* **Can be negative**: ME can be positive, negative, or zero
|
||||
* **Positive ME**: Model under-predicts (actual > predicted on average)
|
||||
* **Negative ME**: Model over-predicts (actual < predicted on average)
|
||||
* **Zero ME**: No systematic bias (but not necessarily accurate)
|
||||
* **Same units**: ME is in the same units as the original data
|
||||
* **Cancellation**: Errors can cancel out, hiding large individual errors
|
||||
|
||||
## Mathematical Foundation
|
||||
|
||||
@@ -31,8 +31,8 @@ $$e_i = y_i - \hat{y}_i$$
|
||||
|
||||
Where:
|
||||
|
||||
- $y_i$ = actual value
|
||||
- $\hat{y}_i$ = predicted value
|
||||
* $y_i$ = actual value
|
||||
* $\hat{y}_i$ = predicted value
|
||||
|
||||
### 2. Mean Calculation
|
||||
|
||||
@@ -131,14 +131,14 @@ Always use ME alongside MAE or MSE to get a complete picture.
|
||||
|
||||
## Edge Cases
|
||||
|
||||
- **Identical Values**: Returns 0 when actual equals predicted
|
||||
- **NaN Handling**: Uses last valid value substitution
|
||||
- **Single Input**: Not supported (requires two series)
|
||||
- **Period = 1**: Returns current signed error
|
||||
- **Balanced Errors**: Can return 0 even with large individual errors
|
||||
* **Identical Values**: Returns 0 when actual equals predicted
|
||||
* **NaN Handling**: Uses last valid value substitution
|
||||
* **Single Input**: Not supported (requires two series)
|
||||
* **Period = 1**: Returns current signed error
|
||||
* **Balanced Errors**: Can return 0 even with large individual errors
|
||||
|
||||
## Related Indicators
|
||||
|
||||
- [MAE](../mae/Mae.md) - Mean Absolute Error (magnitude only)
|
||||
- [MSE](../mse/Mse.md) - Mean Squared Error
|
||||
- [MPE](../mpe/Mpe.md) - Mean Percentage Error (relative bias)
|
||||
* [MAE](../mae/Mae.md) - Mean Absolute Error (magnitude only)
|
||||
* [MSE](../mse/Mse.md) - Mean Squared Error
|
||||
* [MPE](../mpe/Mpe.md) - Mean Percentage Error (relative bias)
|
||||
|
||||
+15
-15
@@ -12,17 +12,17 @@ $$\text{MPE} = \frac{100}{n} \sum_{i=1}^{n} \frac{(\text{actual}_i - \text{predi
|
||||
|
||||
The sign preservation makes MPE invaluable for bias detection:
|
||||
|
||||
- **Positive MPE**: Model systematically under-predicts (actual > predicted)
|
||||
- **Negative MPE**: Model systematically over-predicts (actual < predicted)
|
||||
- **MPE near zero**: No systematic bias (though individual errors may be large)
|
||||
* **Positive MPE**: Model systematically under-predicts (actual > predicted)
|
||||
* **Negative MPE**: Model systematically over-predicts (actual < predicted)
|
||||
* **MPE near zero**: No systematic bias (though individual errors may be large)
|
||||
|
||||
### Bias Detection
|
||||
|
||||
Consider a weather forecasting model:
|
||||
|
||||
- If MPE = +15%, the model consistently predicts temperatures 15% lower than actual
|
||||
- If MPE = -10%, the model consistently predicts temperatures 10% higher than actual
|
||||
- If MPE ≈ 0% but MAPE = 20%, errors cancel out (no bias) but magnitude is still significant
|
||||
* If MPE = +15%, the model consistently predicts temperatures 15% lower than actual
|
||||
* If MPE = -10%, the model consistently predicts temperatures 10% higher than actual
|
||||
* If MPE ≈ 0% but MAPE = 20%, errors cancel out (no bias) but magnitude is still significant
|
||||
|
||||
## Mathematical Foundation
|
||||
|
||||
@@ -122,20 +122,20 @@ Errors of opposite signs cancel out. A model alternating between +50% and -50% e
|
||||
|
||||
**Solution**: Use MPE alongside MAPE:
|
||||
|
||||
- Low MAPE + Low |MPE|: Good model
|
||||
- Low MAPE + High |MPE|: Unlikely (mathematically constrained)
|
||||
- High MAPE + Low |MPE|: High variance, no bias
|
||||
- High MAPE + High |MPE|: High variance with bias
|
||||
* Low MAPE + Low |MPE|: Good model
|
||||
* Low MAPE + High |MPE|: Unlikely (mathematically constrained)
|
||||
* High MAPE + Low |MPE|: High variance, no bias
|
||||
* High MAPE + High |MPE|: High variance with bias
|
||||
|
||||
### 3. Asymmetric Bounds
|
||||
|
||||
Unlike MAPE (bounded at 0% to ∞), MPE can range from -∞ to +100%:
|
||||
|
||||
- Maximum positive: actual = 100, predicted = 0 → MPE = +100%
|
||||
- No upper bound on negative: actual = 100, predicted = 1000 → MPE = -900%
|
||||
* Maximum positive: actual = 100, predicted = 0 → MPE = +100%
|
||||
* No upper bound on negative: actual = 100, predicted = 1000 → MPE = -900%
|
||||
|
||||
## See Also
|
||||
|
||||
- [MAPE](../mape/Mape.md) - Unsigned percentage error for magnitude
|
||||
- [ME](../me/Me.md) - Signed absolute error for absolute bias
|
||||
- [MAE](../mae/Mae.md) - Unsigned absolute error for magnitude
|
||||
* [MAPE](../mape/Mape.md) - Unsigned percentage error for magnitude
|
||||
* [ME](../me/Me.md) - Signed absolute error for absolute bias
|
||||
* [MAE](../mae/Mae.md) - Unsigned absolute error for magnitude
|
||||
|
||||
+13
-13
@@ -14,10 +14,10 @@ MRAE divides each absolute error by the actual value, providing context for the
|
||||
|
||||
### Properties
|
||||
|
||||
- **Scale-independent**: Comparable across different data magnitudes
|
||||
- **Non-negative**: MRAE ≥ 0, with 0 indicating perfect prediction
|
||||
- **Interpretable**: A value of 0.1 means 10% average relative error
|
||||
- **Denominator sensitivity**: Undefined when actual values are zero (handled via substitution)
|
||||
* **Scale-independent**: Comparable across different data magnitudes
|
||||
* **Non-negative**: MRAE ≥ 0, with 0 indicating perfect prediction
|
||||
* **Interpretable**: A value of 0.1 means 10% average relative error
|
||||
* **Denominator sensitivity**: Undefined when actual values are zero (handled via substitution)
|
||||
|
||||
## Mathematical Foundation
|
||||
|
||||
@@ -28,8 +28,8 @@ For each observation, calculate the relative error:
|
||||
$$e_i = \frac{|y_i - \hat{y}_i|}{|y_i|}$$
|
||||
|
||||
Where:
|
||||
- $y_i$ = actual value
|
||||
- $\hat{y}_i$ = predicted value
|
||||
* $y_i$ = actual value
|
||||
* $\hat{y}_i$ = predicted value
|
||||
|
||||
### 2. Mean Calculation
|
||||
|
||||
@@ -114,13 +114,13 @@ Mrae.Batch(actualSpan, predictedSpan, outputSpan, period: 20);
|
||||
|
||||
## Edge Cases
|
||||
|
||||
- **Zero Actual Values**: Substitutes with small epsilon (1e-10) to avoid division by zero
|
||||
- **NaN Handling**: Uses last valid value substitution
|
||||
- **Single Input**: Not supported (requires two series)
|
||||
- **Period = 1**: Returns current relative absolute error
|
||||
* **Zero Actual Values**: Substitutes with small epsilon (1e-10) to avoid division by zero
|
||||
* **NaN Handling**: Uses last valid value substitution
|
||||
* **Single Input**: Not supported (requires two series)
|
||||
* **Period = 1**: Returns current relative absolute error
|
||||
|
||||
## Related Indicators
|
||||
|
||||
- [MAE](../mae/Mae.md) - Mean Absolute Error (non-relative)
|
||||
- [MAPE](../mape/Mape.md) - Mean Absolute Percentage Error
|
||||
- [SMAPE](../smape/Smape.md) - Symmetric Mean Absolute Percentage Error
|
||||
* [MAE](../mae/Mae.md) - Mean Absolute Error (non-relative)
|
||||
* [MAPE](../mape/Mape.md) - Mean Absolute Percentage Error
|
||||
* [SMAPE](../smape/Smape.md) - Symmetric Mean Absolute Percentage Error
|
||||
|
||||
+13
-13
@@ -12,16 +12,16 @@ MSE is fundamental to least-squares regression, dating back to Gauss and Legendr
|
||||
|
||||
MSE squares each error before averaging, which has significant implications:
|
||||
|
||||
- Large errors contribute disproportionately to the metric
|
||||
- The quadratic penalty creates a smooth, differentiable loss surface
|
||||
- Optimal for normally distributed errors
|
||||
* Large errors contribute disproportionately to the metric
|
||||
* The quadratic penalty creates a smooth, differentiable loss surface
|
||||
* Optimal for normally distributed errors
|
||||
|
||||
### Properties
|
||||
|
||||
- **Non-negative**: MSE ≥ 0, with 0 indicating perfect prediction
|
||||
- **Squared units**: If data is in dollars, MSE is in dollars²
|
||||
- **Outlier sensitive**: Single large error dominates the metric
|
||||
- **Differentiable**: Smooth gradient for optimization algorithms
|
||||
* **Non-negative**: MSE ≥ 0, with 0 indicating perfect prediction
|
||||
* **Squared units**: If data is in dollars, MSE is in dollars²
|
||||
* **Outlier sensitive**: Single large error dominates the metric
|
||||
* **Differentiable**: Smooth gradient for optimization algorithms
|
||||
|
||||
## Mathematical Foundation
|
||||
|
||||
@@ -101,12 +101,12 @@ RMSE has the advantage of being in the same units as the original data.
|
||||
|
||||
## Edge Cases
|
||||
|
||||
- **Identical Values**: Returns 0 when actual equals predicted
|
||||
- **NaN Handling**: Uses last valid value substitution
|
||||
- **Large Errors**: Can produce very large values due to squaring
|
||||
* **Identical Values**: Returns 0 when actual equals predicted
|
||||
* **NaN Handling**: Uses last valid value substitution
|
||||
* **Large Errors**: Can produce very large values due to squaring
|
||||
|
||||
## Related Indicators
|
||||
|
||||
- [MAE](../mae/Mae.md) - Mean Absolute Error (robust to outliers)
|
||||
- [RMSE](../rmse/Rmse.md) - Root Mean Squared Error (same units as data)
|
||||
- [Huber](../huber/Huber.md) - Combines MSE and MAE benefits
|
||||
* [MAE](../mae/Mae.md) - Mean Absolute Error (robust to outliers)
|
||||
* [RMSE](../rmse/Rmse.md) - Root Mean Squared Error (same units as data)
|
||||
* [Huber](../huber/Huber.md) - Combines MSE and MAE benefits
|
||||
|
||||
@@ -165,6 +165,6 @@ Near zero, small absolute differences create large MSLE:
|
||||
|
||||
## See Also
|
||||
|
||||
- [RMSLE](../rmsle/Rmsle.md) - Root of MSLE for interpretable units
|
||||
- [MSE](../mse/Mse.md) - Linear-scale squared error
|
||||
- [MAPE](../mape/Mape.md) - Percentage-based comparison
|
||||
* [RMSLE](../rmsle/Rmsle.md) - Root of MSLE for interpretable units
|
||||
* [MSE](../mse/Mse.md) - Linear-scale squared error
|
||||
* [MAPE](../mape/Mape.md) - Percentage-based comparison
|
||||
|
||||
@@ -14,10 +14,10 @@ Pseudo-Huber uses the formula δ²(√(1 + (x/δ)²) - 1), which smoothly interp
|
||||
|
||||
### Properties
|
||||
|
||||
- **Smooth everywhere**: Infinitely differentiable (unlike Huber's kink)
|
||||
- **Non-negative**: Always ≥ 0, with 0 for perfect prediction
|
||||
- **Robust**: Large errors grow linearly, not quadratically
|
||||
- **Tunable**: δ (delta) controls the L2-to-L1 transition point
|
||||
* **Smooth everywhere**: Infinitely differentiable (unlike Huber's kink)
|
||||
* **Non-negative**: Always ≥ 0, with 0 for perfect prediction
|
||||
* **Robust**: Large errors grow linearly, not quadratically
|
||||
* **Tunable**: δ (delta) controls the L2-to-L1 transition point
|
||||
|
||||
## Mathematical Foundation
|
||||
|
||||
@@ -28,8 +28,8 @@ For each error, compute:
|
||||
$$L_\delta(e) = \delta^2 \left(\sqrt{1 + \left(\frac{e}{\delta}\right)^2} - 1\right)$$
|
||||
|
||||
Where:
|
||||
- $e = y - \hat{y}$ = prediction error
|
||||
- $\delta$ = tuning parameter (transition width)
|
||||
* $e = y - \hat{y}$ = prediction error
|
||||
* $\delta$ = tuning parameter (transition width)
|
||||
|
||||
### 2. Asymptotic Behavior
|
||||
|
||||
@@ -46,8 +46,8 @@ $$L_\delta(e) \approx \delta|e| - \delta^2$$
|
||||
$$\frac{dL}{de} = \frac{e}{\sqrt{1 + (e/\delta)^2}}$$
|
||||
|
||||
This approaches:
|
||||
- e for small errors (like L2)
|
||||
- δ·sign(e) for large errors (like L1)
|
||||
* e for small errors (like L2)
|
||||
* δ·sign(e) for large errors (like L1)
|
||||
|
||||
### 4. Running Update (O(1))
|
||||
|
||||
@@ -142,15 +142,15 @@ Pseudo-Huber produces slightly smaller values but follows the same qualitative b
|
||||
|
||||
## Edge Cases
|
||||
|
||||
- **Perfect Predictions**: Returns exactly 0
|
||||
- **NaN Handling**: Uses last valid value substitution
|
||||
- **Single Input**: Not supported (requires two series)
|
||||
- **δ = 0**: Invalid (division by zero)
|
||||
- **Large Errors**: Numerically stable (no overflow)
|
||||
* **Perfect Predictions**: Returns exactly 0
|
||||
* **NaN Handling**: Uses last valid value substitution
|
||||
* **Single Input**: Not supported (requires two series)
|
||||
* **δ = 0**: Invalid (division by zero)
|
||||
* **Large Errors**: Numerically stable (no overflow)
|
||||
|
||||
## Related Indicators
|
||||
|
||||
- [Huber](../huber/Huber.md) - Huber Loss (piecewise, with kink)
|
||||
- [LogCosh](../logcosh/LogCosh.md) - Log-Cosh Loss (different smooth approximation)
|
||||
- [MAE](../mae/Mae.md) - Mean Absolute Error (pure L1)
|
||||
- [MSE](../mse/Mse.md) - Mean Squared Error (pure L2)
|
||||
* [Huber](../huber/Huber.md) - Huber Loss (piecewise, with kink)
|
||||
* [LogCosh](../logcosh/LogCosh.md) - Log-Cosh Loss (different smooth approximation)
|
||||
* [MAE](../mae/Mae.md) - Mean Absolute Error (pure L1)
|
||||
* [MSE](../mse/Mse.md) - Mean Squared Error (pure L2)
|
||||
|
||||
@@ -14,10 +14,10 @@ The loss function applies a multiplier of τ (tau) to under-predictions and (1-
|
||||
|
||||
### Properties
|
||||
|
||||
- **Asymmetric**: Different penalties for under vs. over prediction
|
||||
- **Non-negative**: Always ≥ 0, with 0 for perfect prediction
|
||||
- **Interpretable**: τ directly controls the penalty asymmetry
|
||||
- **Distribution-free**: No assumptions about error distribution
|
||||
* **Asymmetric**: Different penalties for under vs. over prediction
|
||||
* **Non-negative**: Always ≥ 0, with 0 for perfect prediction
|
||||
* **Interpretable**: τ directly controls the penalty asymmetry
|
||||
* **Distribution-free**: No assumptions about error distribution
|
||||
|
||||
## Mathematical Foundation
|
||||
|
||||
@@ -35,9 +35,9 @@ Or equivalently:
|
||||
$$L_\tau(y, \hat{y}) = \max(\tau(y - \hat{y}), (\tau - 1)(y - \hat{y}))$$
|
||||
|
||||
Where:
|
||||
- $y$ = actual value
|
||||
- $\hat{y}$ = predicted value
|
||||
- $\tau$ = target quantile (0 < τ < 1)
|
||||
* $y$ = actual value
|
||||
* $\hat{y}$ = predicted value
|
||||
* $\tau$ = target quantile (0 < τ < 1)
|
||||
|
||||
### 2. Mean Quantile Loss
|
||||
|
||||
@@ -47,9 +47,9 @@ $$QL = \frac{1}{n} \sum_{i=1}^{n} L_\tau(y_i, \hat{y}_i)$$
|
||||
|
||||
### 3. Special Cases
|
||||
|
||||
- **τ = 0.5**: Symmetric loss = 0.5 × MAE (equivalent to median regression)
|
||||
- **τ = 0.9**: 9:1 penalty ratio for under:over prediction
|
||||
- **τ = 0.1**: 1:9 penalty ratio for under:over prediction
|
||||
* **τ = 0.5**: Symmetric loss = 0.5 × MAE (equivalent to median regression)
|
||||
* **τ = 0.9**: 9:1 penalty ratio for under:over prediction
|
||||
* **τ = 0.1**: 1:9 penalty ratio for under:over prediction
|
||||
|
||||
### 4. Running Update (O(1))
|
||||
|
||||
@@ -130,14 +130,14 @@ With τ=0.9, under-predictions are penalized 9x more than over-predictions.
|
||||
|
||||
## Edge Cases
|
||||
|
||||
- **Perfect Predictions**: Returns exactly 0
|
||||
- **τ = 0 or 1**: Invalid (returns division issues)
|
||||
- **NaN Handling**: Uses last valid value substitution
|
||||
- **Single Input**: Not supported (requires two series)
|
||||
- **Period = 1**: Returns current quantile loss
|
||||
* **Perfect Predictions**: Returns exactly 0
|
||||
* **τ = 0 or 1**: Invalid (returns division issues)
|
||||
* **NaN Handling**: Uses last valid value substitution
|
||||
* **Single Input**: Not supported (requires two series)
|
||||
* **Period = 1**: Returns current quantile loss
|
||||
|
||||
## Related Indicators
|
||||
|
||||
- [MAE](../mae/Mae.md) - Mean Absolute Error (equivalent to τ=0.5 × 2)
|
||||
- [Huber](../huber/Huber.md) - Huber Loss (robust symmetric)
|
||||
- [MAPE](../mape/Mape.md) - Mean Absolute Percentage Error
|
||||
* [MAE](../mae/Mae.md) - Mean Absolute Error (equivalent to τ=0.5 × 2)
|
||||
* [Huber](../huber/Huber.md) - Huber Loss (robust symmetric)
|
||||
* [MAPE](../mape/Mape.md) - Mean Absolute Percentage Error
|
||||
|
||||
+10
-9
@@ -11,7 +11,7 @@ RAE computes a ratio of summed absolute errors. The numerator is the sum of abso
|
||||
### Interpretation Guide
|
||||
|
||||
| RAE Value | Interpretation |
|
||||
|:----------|:---------------|
|
||||
| ------ | ------ |
|
||||
| **RAE < 1** | Predictions are better than mean predictor |
|
||||
| **RAE = 1** | Predictions equal mean predictor performance |
|
||||
| **RAE > 1** | Predictions are worse than mean predictor |
|
||||
@@ -38,7 +38,7 @@ $$\text{RAE} = \frac{\sum_{t=1}^{n} |y_t - \hat{y}_t|}{\sum_{t=1}^{n} |y_t - \ba
|
||||
## Performance Profile
|
||||
|
||||
| Metric | Score | Notes |
|
||||
|:-------|:------|:------|
|
||||
| ------ | ------ | ------ |
|
||||
| **Throughput** | ~40 ns/bar | Three running sums maintained |
|
||||
| **Allocations** | 0 | Zero-allocation implementation |
|
||||
| **Complexity** | O(1) | Constant time per update |
|
||||
@@ -59,9 +59,10 @@ The baseline error is calculated against the rolling mean, which updates each ti
|
||||
### Different from R²
|
||||
|
||||
RAE and R² (coefficient of determination) are related but distinct:
|
||||
- RAE uses absolute errors (L1 norm)
|
||||
- R² uses squared errors (L2 norm)
|
||||
- Both use mean-predictor as baseline
|
||||
|
||||
* RAE uses absolute errors (L1 norm)
|
||||
* R² uses squared errors (L2 norm)
|
||||
* Both use mean-predictor as baseline
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -84,7 +85,7 @@ Rae.Batch(actualSpan, predictedSpan, outputSpan, 14);
|
||||
## Comparison with Related Metrics
|
||||
|
||||
| Metric | Error Type | Baseline | Range | Units |
|
||||
|:-------|:-----------|:---------|:------|:------|
|
||||
| ------ | ------ | ------ | ------ | ------ |
|
||||
| **RAE** | Absolute | Mean predictor | [0, ∞) | Ratio |
|
||||
| **RSE** | Squared | Mean predictor | [0, ∞) | Ratio |
|
||||
| **R²** | Squared | Mean predictor | (-∞, 1] | Coefficient |
|
||||
@@ -92,6 +93,6 @@ Rae.Batch(actualSpan, predictedSpan, outputSpan, 14);
|
||||
|
||||
RAE is preferable when:
|
||||
|
||||
- You want robustness to outliers (absolute vs squared errors)
|
||||
- You need a ratio interpretation (< 1 is good, > 1 is bad)
|
||||
- The mean predictor is a relevant baseline for your domain
|
||||
* You want robustness to outliers (absolute vs squared errors)
|
||||
* You need a ratio interpretation (< 1 is good, > 1 is bad)
|
||||
* The mean predictor is a relevant baseline for your domain
|
||||
|
||||
@@ -12,10 +12,10 @@ $$RMSE = \sqrt{\frac{1}{n} \sum_{i=1}^{n} (y_i - \hat{y}_i)^2} = \sqrt{MSE}$$
|
||||
|
||||
## Properties
|
||||
|
||||
- **Non-negative**: RMSE ≥ 0
|
||||
- **Same units**: Unlike MSE, RMSE is in original data units
|
||||
- **Outlier sensitive**: Inherits MSE's penalty for large errors
|
||||
- **Always ≥ MAE**: RMSE ≥ MAE due to Jensen's inequality
|
||||
* **Non-negative**: RMSE ≥ 0
|
||||
* **Same units**: Unlike MSE, RMSE is in original data units
|
||||
* **Outlier sensitive**: Inherits MSE's penalty for large errors
|
||||
* **Always ≥ MAE**: RMSE ≥ MAE due to Jensen's inequality
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -37,5 +37,5 @@ var results = Rmse.Calculate(actualSeries, predictedSeries, period: 20);
|
||||
|
||||
## Related Indicators
|
||||
|
||||
- [MSE](../mse/Mse.md) - Mean Squared Error
|
||||
- [MAE](../mae/Mae.md) - Mean Absolute Error
|
||||
* [MSE](../mse/Mse.md) - Mean Squared Error
|
||||
* [MAE](../mae/Mae.md) - Mean Absolute Error
|
||||
|
||||
@@ -18,9 +18,9 @@ $$\text{RMSLE} = \sqrt{\text{MSLE}}$$
|
||||
|
||||
RMSLE values correspond directly to log-scale error:
|
||||
|
||||
- RMSLE = 0.1 → approximately 10% ratio error
|
||||
- RMSLE = 0.69 → approximately 100% ratio error (2:1 or 1:2 ratio)
|
||||
- RMSLE = 1.0 → approximately 170% ratio error (~2.7:1 ratio)
|
||||
* RMSLE = 0.1 → approximately 10% ratio error
|
||||
* RMSLE = 0.69 → approximately 100% ratio error (2:1 or 1:2 ratio)
|
||||
* RMSLE = 1.0 → approximately 170% ratio error (~2.7:1 ratio)
|
||||
|
||||
## Mathematical Foundation
|
||||
|
||||
@@ -185,6 +185,6 @@ Small absolute values near zero can produce large RMSLE:
|
||||
|
||||
## See Also
|
||||
|
||||
- [MSLE](../msle/Msle.md) - Squared version without root
|
||||
- [RMSE](../rmse/Rmse.md) - Linear-scale root mean squared error
|
||||
- [MAPE](../mape/Mape.md) - Percentage error without log transform
|
||||
* [MSLE](../msle/Msle.md) - Squared version without root
|
||||
* [RMSE](../rmse/Rmse.md) - Linear-scale root mean squared error
|
||||
* [MAPE](../mape/Mape.md) - Percentage error without log transform
|
||||
|
||||
@@ -11,7 +11,7 @@ RSE computes a ratio of summed squared errors. The numerator is the residual sum
|
||||
### Interpretation Guide
|
||||
|
||||
| RSE Value | R² Value | Interpretation |
|
||||
|:----------|:---------|:---------------|
|
||||
| :-------- | :------- | :------------- |
|
||||
| **RSE = 0** | **R² = 1** | Perfect predictions |
|
||||
| **RSE < 1** | **R² > 0** | Better than mean predictor |
|
||||
| **RSE = 1** | **R² = 0** | Same as mean predictor |
|
||||
@@ -42,7 +42,7 @@ $$R^2 = 1 - \text{RSE}$$
|
||||
## Performance Profile
|
||||
|
||||
| Metric | Score | Notes |
|
||||
|:-------|:------|:------|
|
||||
| :----- | :---- | :---- |
|
||||
| **Throughput** | ~40 ns/bar | Three running sums maintained |
|
||||
| **Allocations** | 0 | Zero-allocation implementation |
|
||||
| **Complexity** | O(1) | Constant time per update |
|
||||
@@ -86,7 +86,7 @@ Rse.Batch(actualSpan, predictedSpan, outputSpan, 14);
|
||||
## RSE vs R² Quick Reference
|
||||
|
||||
| Scenario | RSE | R² | Quality |
|
||||
|:---------|:----|:---|:--------|
|
||||
| :------- | :-- | :- | :------ |
|
||||
| Perfect model | 0.00 | 1.00 | Excellent |
|
||||
| Very good model | 0.05 | 0.95 | Very good |
|
||||
| Good model | 0.20 | 0.80 | Good |
|
||||
@@ -97,7 +97,7 @@ Rse.Batch(actualSpan, predictedSpan, outputSpan, 14);
|
||||
## Comparison with RAE
|
||||
|
||||
| Property | RSE | RAE |
|
||||
|:---------|:----|:----|
|
||||
| :------- | :-- | :-- |
|
||||
| **Error type** | Squared (L2) | Absolute (L1) |
|
||||
| **Outlier sensitivity** | High | Low |
|
||||
| **Related to** | R² | — |
|
||||
|
||||
@@ -11,7 +11,7 @@ R² is computed as 1 minus the ratio of residual sum of squares (RSS) to total s
|
||||
### Interpretation Guide
|
||||
|
||||
| R² Value | Interpretation |
|
||||
|:---------|:---------------|
|
||||
| :------- | :------------- |
|
||||
| **R² = 1** | Perfect predictions (all variance explained) |
|
||||
| **R² > 0.9** | Excellent model |
|
||||
| **R² > 0.7** | Good model |
|
||||
@@ -42,7 +42,7 @@ $$R^2 = 1 - \text{RSE}$$
|
||||
## Performance Profile
|
||||
|
||||
| Metric | Score | Notes |
|
||||
|:-------|:------|:------|
|
||||
| :----- | :---- | :---- |
|
||||
| **Throughput** | ~40 ns/bar | Three running sums maintained |
|
||||
| **Allocations** | 0 | Zero-allocation implementation |
|
||||
| **Complexity** | O(1) | Constant time per update |
|
||||
@@ -89,7 +89,7 @@ Rsquared.Batch(actualSpan, predictedSpan, outputSpan, 14);
|
||||
## R² Quick Reference
|
||||
|
||||
| R² Value | Quality | Description |
|
||||
|:---------|:--------|:------------|
|
||||
| :------- | :------ | :---------- |
|
||||
| 1.00 | Perfect | Model explains all variance |
|
||||
| 0.95 | Excellent | Model explains 95% of variance |
|
||||
| 0.80 | Good | Model explains 80% of variance |
|
||||
@@ -100,7 +100,7 @@ Rsquared.Batch(actualSpan, predictedSpan, outputSpan, 14);
|
||||
## Comparison with RSE
|
||||
|
||||
| Property | R² | RSE |
|
||||
|:---------|:---|:----|
|
||||
| :------- | :- | :-- |
|
||||
| **Range** | (-∞, 1] | [0, +∞) |
|
||||
| **Perfect score** | 1 | 0 |
|
||||
| **Mean predictor** | 0 | 1 |
|
||||
@@ -109,6 +109,6 @@ Rsquared.Batch(actualSpan, predictedSpan, outputSpan, 14);
|
||||
|
||||
## When to Use R²
|
||||
|
||||
- **Use R²** when you want an intuitive measure of model quality (0-1 scale for good models)
|
||||
- **Use RSE** when you want to compare error magnitudes directly
|
||||
- **Use both** to get complementary perspectives on model performance
|
||||
* **Use R²** when you want an intuitive measure of model quality (0-1 scale for good models)
|
||||
* **Use RSE** when you want to compare error magnitudes directly
|
||||
* **Use both** to get complementary perspectives on model performance
|
||||
|
||||
+10
-10
@@ -18,13 +18,13 @@ Consider predicting a value of 80 when actual is 100, versus predicting 100 when
|
||||
|
||||
**MAPE calculations:**
|
||||
|
||||
- Case 1: $100 \times |100-80|/100 = 20\%$
|
||||
- Case 2: $100 \times |80-100|/80 = 25\%$
|
||||
* Case 1: $100 \times |100-80|/100 = 20\%$
|
||||
* Case 2: $100 \times |80-100|/80 = 25\%$
|
||||
|
||||
**SMAPE calculations:**
|
||||
|
||||
- Case 1: $200 \times |100-80|/(100+80) = 22.2\%$
|
||||
- Case 2: $200 \times |80-100|/(80+100) = 22.2\%$
|
||||
* Case 1: $200 \times |100-80|/(100+80) = 22.2\%$
|
||||
* Case 2: $200 \times |80-100|/(80+100) = 22.2\%$
|
||||
|
||||
SMAPE assigns identical penalties regardless of which value is larger.
|
||||
|
||||
@@ -46,9 +46,9 @@ $$\text{SMAPE}_t = \frac{1}{n} \sum_{i=t-n+1}^{t} e_i$$
|
||||
|
||||
SMAPE is bounded between 0% and 200%:
|
||||
|
||||
- **0%**: Perfect prediction (actual = predicted)
|
||||
- **200%**: Maximum error (one value is 0, other is non-zero)
|
||||
- **100%**: Occurs when |actual - predicted| = (|actual| + |predicted|)/2
|
||||
* **0%**: Perfect prediction (actual = predicted)
|
||||
* **200%**: Maximum error (one value is 0, other is non-zero)
|
||||
* **100%**: Occurs when |actual - predicted| = (|actual| + |predicted|)/2
|
||||
|
||||
## Performance Profile
|
||||
|
||||
@@ -142,6 +142,6 @@ This scales to 0-100% but is mathematically equivalent to the 0-200% version. Qu
|
||||
|
||||
## See Also
|
||||
|
||||
- [MAPE](../mape/Mape.md) - Asymmetric percentage error
|
||||
- [MPE](../mpe/Mpe.md) - Signed percentage error for bias
|
||||
- [MAE](../mae/Mae.md) - Absolute error without scaling
|
||||
* [MAPE](../mape/Mape.md) - Asymmetric percentage error
|
||||
* [MPE](../mpe/Mpe.md) - Signed percentage error for bias
|
||||
* [MAE](../mae/Mae.md) - Absolute error without scaling
|
||||
|
||||
+14
-14
@@ -14,10 +14,10 @@ Theil's U computes two parallel error metrics: one for the forecast and one for
|
||||
|
||||
### Properties
|
||||
|
||||
- **Relative benchmark**: Compares against naive no-change forecast
|
||||
- **Scale-independent**: Ratio is unitless
|
||||
- **Interpretable threshold**: U = 1 is the break-even point
|
||||
- **Range**: 0 to ∞, with 0 being perfect and > 1 being worse than naive
|
||||
* **Relative benchmark**: Compares against naive no-change forecast
|
||||
* **Scale-independent**: Ratio is unitless
|
||||
* **Interpretable threshold**: U = 1 is the break-even point
|
||||
* **Range**: 0 to ∞, with 0 being perfect and > 1 being worse than naive
|
||||
|
||||
## Mathematical Foundation
|
||||
|
||||
@@ -28,8 +28,8 @@ Calculate squared errors for the actual forecast:
|
||||
$$FPE = \sum_{i=1}^{n} (y_i - \hat{y}_i)^2$$
|
||||
|
||||
Where:
|
||||
- $y_i$ = actual value at time i
|
||||
- $\hat{y}_i$ = predicted value at time i
|
||||
* $y_i$ = actual value at time i
|
||||
* $\hat{y}_i$ = predicted value at time i
|
||||
|
||||
### 2. Naive Error
|
||||
|
||||
@@ -123,14 +123,14 @@ TheilU.Batch(actualSpan, predictedSpan, outputSpan, period: 20);
|
||||
|
||||
## Edge Cases
|
||||
|
||||
- **Zero Naive Error**: Returns infinity when series is perfectly flat (naive is perfect)
|
||||
- **NaN Handling**: Uses last valid value substitution
|
||||
- **Single Input**: Not supported (requires two series)
|
||||
- **Period = 1**: Returns 0 (insufficient data for naive comparison)
|
||||
- **First Value**: Needs at least 2 values for naive benchmark
|
||||
* **Zero Naive Error**: Returns infinity when series is perfectly flat (naive is perfect)
|
||||
* **NaN Handling**: Uses last valid value substitution
|
||||
* **Single Input**: Not supported (requires two series)
|
||||
* **Period = 1**: Returns 0 (insufficient data for naive comparison)
|
||||
* **First Value**: Needs at least 2 values for naive benchmark
|
||||
|
||||
## Related Indicators
|
||||
|
||||
- [RMSE](../rmse/Rmse.md) - Root Mean Squared Error (absolute, not relative)
|
||||
- [MASE](../mase/Mase.md) - Mean Absolute Scaled Error (similar concept)
|
||||
- [R-Squared](../rsquared/RSquared.md) - Coefficient of Determination
|
||||
* [RMSE](../rmse/Rmse.md) - Root Mean Squared Error (absolute, not relative)
|
||||
* [MASE](../mase/Mase.md) - Mean Absolute Scaled Error (similar concept)
|
||||
* [R-Squared](../rsquared/RSquared.md) - Coefficient of Determination
|
||||
|
||||
@@ -14,10 +14,10 @@ The biweight function is a smooth, bell-shaped curve that rises from 0, peaks at
|
||||
|
||||
### Properties
|
||||
|
||||
- **Redescending**: Large errors contribute zero loss (complete outlier rejection)
|
||||
- **Smooth**: Continuously differentiable everywhere
|
||||
- **Bounded**: Maximum loss is c²/6, regardless of error magnitude
|
||||
- **Tunable**: Parameter c controls the outlier threshold
|
||||
* **Redescending**: Large errors contribute zero loss (complete outlier rejection)
|
||||
* **Smooth**: Continuously differentiable everywhere
|
||||
* **Bounded**: Maximum loss is c²/6, regardless of error magnitude
|
||||
* **Tunable**: Parameter c controls the outlier threshold
|
||||
|
||||
## Mathematical Foundation
|
||||
|
||||
@@ -31,8 +31,8 @@ $$\rho(e) = \begin{cases}
|
||||
\end{cases}$$
|
||||
|
||||
Where:
|
||||
- $e = y - \hat{y}$ = prediction error
|
||||
- $c$ = tuning constant (threshold)
|
||||
* $e = y - \hat{y}$ = prediction error
|
||||
* $c$ = tuning constant (threshold)
|
||||
|
||||
### 2. Alternative Form
|
||||
|
||||
@@ -44,9 +44,9 @@ where $u = e/c$
|
||||
|
||||
### 3. Key Values
|
||||
|
||||
- At $e = 0$: $\rho(0) = 0$
|
||||
- At $e = c$: $\rho(c) = c^2/6$ (maximum)
|
||||
- For $|e| > c$: $\rho(e) = c^2/6$ (constant, flat)
|
||||
* At $e = 0$: $\rho(0) = 0$
|
||||
* At $e = c$: $\rho(c) = c^2/6$ (maximum)
|
||||
* For $|e| > c$: $\rho(e) = c^2/6$ (constant, flat)
|
||||
|
||||
### 4. Running Update (O(1))
|
||||
|
||||
@@ -133,15 +133,15 @@ Tukey's biweight is the only loss function that completely stops penalizing erro
|
||||
|
||||
## Edge Cases
|
||||
|
||||
- **Perfect Predictions**: Returns exactly 0
|
||||
- **All Outliers**: Returns c²/6 (maximum bounded loss)
|
||||
- **NaN Handling**: Uses last valid value substitution
|
||||
- **Single Input**: Not supported (requires two series)
|
||||
- **c = 0**: Invalid (division issues)
|
||||
- **Errors exactly at c**: Smooth transition (differentiable)
|
||||
* **Perfect Predictions**: Returns exactly 0
|
||||
* **All Outliers**: Returns c²/6 (maximum bounded loss)
|
||||
* **NaN Handling**: Uses last valid value substitution
|
||||
* **Single Input**: Not supported (requires two series)
|
||||
* **c = 0**: Invalid (division issues)
|
||||
* **Errors exactly at c**: Smooth transition (differentiable)
|
||||
|
||||
## Related Indicators
|
||||
|
||||
- [Huber](../huber/Huber.md) - Huber Loss (linear, not redescending)
|
||||
- [MdAE](../mdae/Mdae.md) - Median Absolute Error (robust via median)
|
||||
- [LogCosh](../logcosh/LogCosh.md) - Log-Cosh Loss (smooth L1/L2 hybrid)
|
||||
* [Huber](../huber/Huber.md) - Huber Loss (linear, not redescending)
|
||||
* [MdAE](../mdae/Mdae.md) - Median Absolute Error (robust via median)
|
||||
* [LogCosh](../logcosh/LogCosh.md) - Log-Cosh Loss (smooth L1/L2 hybrid)
|
||||
|
||||
+13
-13
@@ -12,12 +12,12 @@ WMAPE emerged from retail and supply chain forecasting where aggregate accuracy
|
||||
|
||||
WMAPE accumulates both absolute errors and actual values, then computes their ratio. This approach means larger actual values contribute proportionally more to the final metric, providing a volume-weighted view of accuracy.
|
||||
|
||||
### Properties
|
||||
### Characteristics
|
||||
|
||||
- **Volume-weighted**: High-value items contribute more to the metric
|
||||
- **Scale-independent**: Result is always a percentage
|
||||
- **Non-negative**: WMAPE ≥ 0, with 0 indicating perfect prediction
|
||||
- **Aggregate interpretation**: Represents total error as percentage of total actual
|
||||
* **Volume-weighted**: High-value items contribute more to the metric
|
||||
* **Scale-independent**: Result is always a percentage
|
||||
* **Non-negative**: WMAPE ≥ 0, with 0 indicating perfect prediction
|
||||
* **Aggregate interpretation**: Represents total error as percentage of total actual
|
||||
|
||||
## Mathematical Foundation
|
||||
|
||||
@@ -126,14 +126,14 @@ WMAPE gives less weight to the small-volume item with high percentage error.
|
||||
|
||||
## Edge Cases
|
||||
|
||||
- **Zero Actual Sum**: Returns 0 when total actual is zero (handled via substitution)
|
||||
- **NaN Handling**: Uses last valid value substitution
|
||||
- **Single Input**: Not supported (requires two series)
|
||||
- **Period = 1**: Returns current weighted percentage error
|
||||
- **All Zero Actuals**: Uses epsilon substitution
|
||||
* **Zero Actual Sum**: Returns 0 when total actual is zero (handled via substitution)
|
||||
* **NaN Handling**: Uses last valid value substitution
|
||||
* **Single Input**: Not supported (requires two series)
|
||||
* **Period = 1**: Returns current weighted percentage error
|
||||
* **All Zero Actuals**: Uses epsilon substitution
|
||||
|
||||
## Related Indicators
|
||||
|
||||
- [MAPE](../mape/Mape.md) - Mean Absolute Percentage Error (unweighted)
|
||||
- [MAE](../mae/Mae.md) - Mean Absolute Error (non-percentage)
|
||||
- [SMAPE](../smape/Smape.md) - Symmetric MAPE
|
||||
* [MAPE](../mape/Mape.md) - Mean Absolute Percentage Error (unweighted)
|
||||
* [MAE](../mae/Mae.md) - Mean Absolute Error (non-percentage)
|
||||
* [SMAPE](../smape/Smape.md) - Symmetric MAPE
|
||||
|
||||
Reference in New Issue
Block a user