scoring
darts_segmentation.training.scoring
¶
Scoring calculation.
check_score_is_unstable
¶
Check the stability of the scoring metric.
If any metric value is not finite or equal to zero, the scoring metric is considered unstable.
Parameters:
Returns:
-
bool
(bool
) –True if the scoring metric is unstable, False otherwise.
Raises:
-
ValueError
–If an unknown scoring metric type is provided.
Source code in darts-segmentation/src/darts_segmentation/training/scoring.py
score_from_runs
¶
score_from_runs(
run_infos: list[dict[str, float]],
scoring_metric: list[str] | str,
multi_score_strategy: typing.Literal[
"harmonic", "arithmetic", "geometric", "min"
] = "harmonic",
) -> float
Calculate a score from run metrics.
Each metric can be provided by either ":higher" or ":lower" to indicate the direction of the metrics. This allows to correctly combine multiple metrics by doing 1/metric before calculation if a metric is ":lower". If no direction is provided, it is assumed to be ":higher". Has no real effect on the single score calculation, since only the mean is calculated there.
In a multi-score setting, the score is calculated by combine-then-reduce the metrics. Meaning that first for each run the metrics are combined using the specified strategy, and then the results are reduced via mean. Please refer to the documentation to understand the different multi-score strategies.
Ignores unstable runs when multi_score_strategy is "harmonic" or "geometric" If no runs are left, return 0. An unstable run is where one of the metrics is not finite or zero.
Parameters:
-
run_infos
(list[dict[str, float]]
) –List of dictionaries containing run information and metrics
-
scoring_metric
(list[str] | str
) –Metric(s) to use for scoring.
-
multi_score_strategy
(typing.Literal['harmonic', 'arithmetic', 'geometric', 'min']
, default:'harmonic'
) –Strategy for combining multiple metrics. Defaults to "harmonic".
Returns:
-
float
(float
) –The calculated score
Raises:
-
ValueError
–If an unknown multi-score strategy is provided.
Source code in darts-segmentation/src/darts_segmentation/training/scoring.py
score_from_single_run
¶
score_from_single_run(
run_info: dict[str, float],
scoring_metric: list[str] | str,
multi_score_strategy: typing.Literal[
"harmonic", "arithmetic", "geometric", "min"
] = "harmonic",
) -> float
Calculate a score from run metrics.
Each metric can be provided by either ":higher" or ":lower" to indicate the direction of the metrics. This allows to correctly combine multiple metrics by doing 1/metric before calculation if a metric is ":lower". If no direction is provided, it is assumed to be ":higher". Has no real effect on the single score calculation, since only the mean is calculated there.
In a multi-score setting, the score is calculated by combining the metrics through the specified strategy. Please refer to the documentation to understand the different multi-score strategies.
Unstable runs when multi_score_strategy is "harmonic" or "geometric" will result in a score of 0. An unstable run is where one of the metrics is not finite or zero.
Parameters:
-
run_info
(dict[str, float]
) –Dictionary containing run information and metrics
-
scoring_metric
(list[str] | str
) –Metric(s) to use for scoring.
-
multi_score_strategy
(typing.Literal['harmonic', 'arithmetic', 'geometric', 'min']
, default:'harmonic'
) –Strategy for combining multiple metrics. Defaults to "harmonic".
Returns:
-
float
(float
) –The calculated score
Raises:
-
ValueError
–If an unknown multi-score strategy is provided.