CrossValidateResult
Module: strata.model_selection • Kind: struct • Traits: Movable
Source: strata/model_selection/validation.mojo
struct CrossValidateResult(Movable)from strata.model_selection import CrossValidateResultPer-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].
Constructors
Section titled “Constructors”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. |
Methods Overview
Section titled “Methods Overview”| 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. |
Method Details
Section titled “Method Details”CrossValidateResult.metric_index()
Section titled “CrossValidateResult.metric_index()”def metric_index(self, metric: String) -> IntReturns 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.
CrossValidateResult.test_scores_for()
Section titled “CrossValidateResult.test_scores_for()”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.
CrossValidateResult.train_scores_for()
Section titled “CrossValidateResult.train_scores_for()”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.