A10 - A10 Index =============== .. toctree:: :maxdepth: 3 .. contents:: Table of Contents :local: :depth: 2 The **A10 Index** is a strictly threshold-based regression metric widely used in engineering and empirical models. It quantifies the proportion of predictions that deviate by no more than **±10%** from the actual ground truth values. .. math:: \text{A10}(y, \hat{y}) = \frac{1}{N} \sum_{i=1}^{N} \begin{cases} 1, & \text{if } \frac{|y_i - \hat{y}_i|}{|y_i|} \leq 0.1 \\ 0, & \text{otherwise} \end{cases} ------------------------------------------------------------------------------- Description ----------- **Advantages:** * **Exceptional interpretability:** Directly translates into business, engineering, or clinical success criteria (e.g., "85% of our predictions fall within the strict 10% margin of error"). * **Robust to extreme outliers:** Unlike RMSE or MSE, massive prediction errors do not disproportionately skew the final score. An outlier is simply counted as a failure (score = 0). **Disadvantages:** * **Rigid threshold (Cliff effect):** A prediction with a 10.1% error is penalized exactly the same as a prediction with a 500% error. It completely ignores "near-misses". * **Undefined for zero targets:** Because it divides by the actual value (:math:`y_i`), the metric calculation will crash or become undefined if the ground truth data contains absolute zeros. ------------------------------------------------------------------------------- Properties ---------- * **Best possible score:** ``1.0`` (Higher is better, meaning 100% of samples are within the ±10% tolerance zone). * **Range:** ``[0.0, 1.0]`` * **Mathematical Reference:** `MDPI Applied Sciences `_ ------------------------------------------------------------------------------- Example Usage ------------- .. code-block:: python :emphasize-lines: 10, 18 from numpy import array from permetrics.regression import RegressionMetric ## 1. For 1-D array (Single-output) y_true = array([3, -0.5, 2, 7]) y_pred = array([2.5, 0.0, 2, 8]) evaluator = RegressionMetric(y_true, y_pred) # Calculate A10 Index print("A10 Index: ", evaluator.A10()) ## 2. For > 1-D array (Multi-output) y_true = array([[0.5, 1], [-1, 1], [7, -6]]) y_pred = array([[0, 2], [-1, 2], [8, -5]]) evaluator = RegressionMetric(y_true, y_pred) # Return an array of scores for each column print("A10 Index (Multi-output): ", evaluator.A10(multi_output="raw_values"))