spectrochempy.CrossValidationResult

class CrossValidationResult[source]

Structured result returned by cross_validate.

This frozen record owns isolated copies of its dataset inputs, fold positions, configuration snapshots, and tracking containers. Its NDDataset members remain mutable, so the result is not deeply immutable. It is not persistent and does not provide replay or automatic provenance. Instances are created only by cross_validate; direct construction is not supported.

estimator[source]

Non-executable estimator configuration snapshot. It exposes class_name, parameters, and, for a Pipeline, ordered steps.

Type

object

splitter[source]

Non-executable splitter snapshot exposing class_name and parameters.

Type

object

n_splits[source]

Number of validated folds.

Type

int

sample_dim[source]

Observation dimension name shared by X and y.

Type

str

x_sample_axis, y_sample_axis

Original observation-axis positions in X and y.

Type

int

observation_coordinate[source]

Isolated observation coordinate when one is available.

Type

Coord or None

groups[source]

Compact group summary exposing n_groups and ordered counts.

Type

object or None

observed, oof_predictions, residuals

Isolated target datasets in the original y geometry and units.

Type

NDDataset

global_metrics[source]

Requested global metrics in caller order. Prefer metric for lookup by name.

Type

tuple of CrossValidationMetric

n_valid[source]

Number of finite, unmasked observed/predicted pairs per target.

Type

NDDataset

folds[source]

Fold records in splitter order. Each record exposes fold_index, read-only train_positions and validation_positions, n_valid, and CrossValidationFoldResult.metric.

Type

tuple of CrossValidationFoldResult

warnings[source]

Validation warnings. V1 normally returns an empty tuple.

Type

tuple of str

undefined_metrics[source]

Explicit records exposing metric scope, target, reason, and optional fold index whenever a requested metric is undefined.

Type

tuple

fold_estimators[source]

Independent fitted fold estimators only when requested. Retaining them can substantially increase memory use because each estimator is copied.

Type

tuple or None

operation[source]

Minimal non-executable operation description. It is not provenance or a replay specification.

Type

object

See also

cross_validate

Evaluate a fixed supervised regression configuration.

Examples

>>> values = np.arange(24.0).reshape(8, 3)
>>> X = scp.NDDataset(values, dims=["y", "x"])
>>> y = scp.NDDataset((1.0 + values[:, 0])[:, None], dims=["y", "t"])
>>> model = scp.PLSRegression(n_components=1, scale=False)
>>> result = scp.cross_validate(model, X, y, cv=4)
>>> isinstance(result, scp.CrossValidationResult)
True

Methods Summary

metric(name)

Return a requested global metric by its public name.

Methods Documentation

metric(name)[source]

Return a requested global metric by its public name.

Parameters

name ({“rmsecv”, “r2”, “bias”, “mae”}) – Metric selected in the original cross_validate call.

Returns

CrossValidationMetric – Frozen record containing name, an NDDataset in target geometry under values, per-target boolean defined flags, and matching reason codes under reasons. RMSECV, bias, and MAE carry target units; R² is unitless.

Raises

KeyError – If name was not requested.

Examples using spectrochempy.CrossValidationResult