Index
benchmark ¶
The benchmark module contains classes for evaluating the performance of a model on a dataset.
BaseEvaluator ¶
BaseEvaluator(
task: Literal[
"trajectory_regression",
"regression",
"poi_prediction",
"mobility_prediction",
],
)
Bases: ABC
Abstract class for benchmark evaluators.
Source code in srai/benchmark/_base.py
evaluate ¶
abstractmethod
evaluate(
dataset: sds.PointDataset | sds.TrajectoryDataset,
predictions: np.ndarray,
log_metrics: bool = True,
hf_token: Optional[str] = None,
**kwargs: Any
) -> dict[str, float]
Evaluate predictions againts test set.
PARAMETER | DESCRIPTION |
---|---|
dataset
|
Dataset to evaluate on.
TYPE:
|
predictions
|
Predictions returned by your model.
TYPE:
|
log_metrics
|
If True, logs metrics to the console. Defaults to True.
TYPE:
|
hf_token
|
If needed, a User Access Token needed to authenticate to HF Defaults to None.
TYPE:
|
**kwargs
|
Additional keyword arguments depending on the task.
TYPE:
|
PARAMETER | DESCRIPTION |
---|---|
region_ids |
List of region IDs. Required for region-based evaluators.
TYPE:
|
point_of_interests |
Points of interest. Required for point-based evaluators.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
dict[str, float]
|
dict[str, float]: Dictionary with metrics values for the task. |
Note
Specific subclasses may require different sets of keyword arguments.
Source code in srai/benchmark/_base.py
HexRegressionEvaluator ¶
Bases: BaseEvaluator
Evaluator for regression task.
Source code in srai/benchmark/hex_regression_evaluator.py
evaluate ¶
evaluate(
dataset: sds.PointDataset | sds.TrajectoryDataset,
predictions: np.ndarray,
log_metrics: bool = True,
hf_token: Optional[str] = None,
**kwargs: Any
) -> dict[str, float]
Evaluate regression predictions against test set.
This regression evaluator is designed for H3 grid predictions. Metrics are calculated for each h3 where at least one data point is present (empty regions are not taken into account).
PARAMETER | DESCRIPTION |
---|---|
dataset
|
Dataset to evaluate.
TYPE:
|
predictions
|
Predictions returned by your model. Should match regions_id.
TYPE:
|
log_metrics
|
If True, logs metrics to the console. Defaults to True.
TYPE:
|
hf_token
|
If needed, a User Access Token needed to authenticate to HF Defaults to None.
TYPE:
|
**kwargs
|
Additional keyword arguments.
TYPE:
|
PARAMETER | DESCRIPTION |
---|---|
region_ids |
List of region IDs. Required for region-based evaluators.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
ValueError
|
If region id for H3 index not found in region_ids. |
RETURNS | DESCRIPTION |
---|---|
dict[str, float]
|
dict[str, float]: Dictionary with metrics values for the task. |
Source code in srai/benchmark/hex_regression_evaluator.py
MobilityPredictionEvaluator ¶
Bases: BaseEvaluator
Evaluator for models predicting H3 index trajectories directly.
k (int) : If set, only the first k elements of each sequence are used for metrics computation. Defaults to np.inf (use full sequences).
Source code in srai/benchmark/mobility_prediction_evaluator.py
evaluate ¶
evaluate(
dataset: sds.PointDataset | sds.TrajectoryDataset,
predictions: list[list[str]],
log_metrics: bool = True,
hf_token: Optional[str] = None,
**kwargs: Any
) -> dict[str, float]
Evaluate predicted H3 index sequences against ground truth H3 sequences.
PARAMETER | DESCRIPTION |
---|---|
dataset
|
Dataset to evaluate.
TYPE:
|
predictions
|
Predicted sequences of H3 indexes.
TYPE:
|
log_metrics
|
If True, logs metrics.
TYPE:
|
hf_token
|
Ignored.
TYPE:
|
**kwargs
|
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
dict[str, float]
|
dict[str, float]: Evaluation metrics. |
Source code in srai/benchmark/mobility_prediction_evaluator.py
TrajectoryRegressionEvaluator ¶
Bases: BaseEvaluator
Evaluator for regression task.
Source code in srai/benchmark/trajectory_regression_evaluator.py
evaluate ¶
evaluate(
dataset: sds.PointDataset | sds.TrajectoryDataset,
predictions: np.ndarray,
log_metrics: bool = True,
hf_token: Optional[str] = None,
**kwargs: Any
) -> dict[str, float]
Evaluate regression predictions against test set.
This regression evaluator is designed for predictions for h3 grid trajectories.
PARAMETER | DESCRIPTION |
---|---|
dataset
|
Dataset to evaluate.
TYPE:
|
predictions
|
Predictions returned by your model. Should match trip_id.
TYPE:
|
log_metrics
|
If True, logs metrics to the console. Defaults to True.
TYPE:
|
hf_token
|
If needed, a User Access Token needed to authenticate to HF Defaults to None.
TYPE:
|
**kwargs
|
Additional keyword arguments.
TYPE:
|
PARAMETER | DESCRIPTION |
---|---|
trip_ids |
List of region IDs. Required for region-based evaluators.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
ValueError
|
If region id for H3 index not found in region_ids. |
RETURNS | DESCRIPTION |
---|---|
dict[str, float]
|
dict[str, float]: Dictionary with metrics values for the task. |