custom metrics
benchmark._custom_metrics ¶
Metrics module.
This module contains implementation of non-standard metrics used by evaluators.
dtw_distance ¶
Compute Dynamic Time Warping distance between two sequences of H3 cells.
PARAMETER | DESCRIPTION |
---|---|
true_h3_seq
|
Ground truth sequence of H3 cell indexes.
TYPE:
|
pred_h3_seq
|
Predicted sequence of H3 cell indexes.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
float
|
DTW distance between the latitude-longitude paths of the two sequences.
TYPE:
|
Source code in srai/benchmark/_custom_metrics.py
haversine_sequence ¶
Compute the average Haversine distance between pairs of H3 cells.
PARAMETER | DESCRIPTION |
---|---|
true_h3_seq
|
Ground truth sequence of H3 cell indexes.
TYPE:
|
pred_h3_seq
|
Predicted sequence of H3 cell indexes.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
float
|
Mean Haversine distance in meters between corresponding H3 pairs. Returns float('inf') if no valid pairs are found.
TYPE:
|
Source code in srai/benchmark/_custom_metrics.py
mean_absolute_percentage_error ¶
mean_absolute_percentage_error(
y_true: np.ndarray, y_pred: np.ndarray, epsilon: float = 1e-10
) -> float
Calculates regression metric: Mean Absolute Percentage Error.
PARAMETER | DESCRIPTION |
---|---|
y_true
|
Expected values
TYPE:
|
y_pred
|
Predicted values
TYPE:
|
epsilon
|
Small constant to avoid division by zero (default: 1e-10)
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
float
|
Mean absolute percentage error value
TYPE:
|
Source code in srai/benchmark/_custom_metrics.py
sequence_accuracy ¶
Compute accuracy of predicted H3 sequence by exact element-wise match.
PARAMETER | DESCRIPTION |
---|---|
true
|
Ground truth sequence of H3 indexes.
TYPE:
|
pred
|
Predicted sequence of H3 indexes.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
float
|
Proportion of elements that match exactly.
TYPE:
|
Source code in srai/benchmark/_custom_metrics.py
symmetric_mean_absolute_percentage_error ¶
symmetric_mean_absolute_percentage_error(
y_true: np.ndarray, y_pred: np.ndarray, epsilon: float = 1e-10
) -> float
Calculates regression metric: Symmetric Mean Absolute Percentage Error.
PARAMETER | DESCRIPTION |
---|---|
y_true
|
Expected values
TYPE:
|
y_pred
|
Predicted values
TYPE:
|
epsilon
|
Small constant to avoid division by zero (default: 1e-10)
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
float
|
Symmetric mean absolute percentage error value
TYPE:
|