Skip to content

CrossValidateResult

Module: strata.model_selection • Kind: struct • Traits: Movable
Source: strata/model_selection/validation.mojo

struct CrossValidateResult(Movable)
from strata.model_selection import CrossValidateResult

Per-fold scores for one or more metrics from a cross-validation run.

Scores are stored as parallel lists: metrics[m] names the metric whose per-fold values are held in test_scores[m] and, when requested, train_scores[m].


def __init__(
out self,
var metrics: List[String],
var test_scores: List[List[Float64]],
var train_scores: List[List[Float64]],
)

Initializes a cross-validation result.

Argument Type Description
metrics — Names of the evaluated metrics.
test_scores — Validation-fold scores for each metric.
train_scores — Training-fold scores for each metric, or an empty list when training scores were not requested.

Method Description
CrossValidateResult.metric_index() Returns the position of a metric name within this result.
CrossValidateResult.test_scores_for() Returns the per-fold validation scores for a named metric.
CrossValidateResult.train_scores_for() Returns the per-fold training scores for a named metric.

def metric_index(self, metric: String) -> Int

Returns the position of a metric name within this result.

Parameter Type Description
metric String Name of a metric evaluated during cross-validation.

Returns: Int — Index into the metrics, test_scores, and train_scores lists.


def test_scores_for(self, metric: String) -> List[Float64]

Returns the per-fold validation scores for a named metric.

Parameter Type Description
metric String Name of a metric evaluated during cross-validation.

Returns: List[Float64] — One score per fold, in fold order.


def train_scores_for(self, metric: String) -> List[Float64]

Returns the per-fold training scores for a named metric.

Parameter Type Description
metric String Name of a metric evaluated during cross-validation.

Returns: List[Float64] — One score per fold, in fold order.