package modelkit
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=1fe8fa7c7f904dd098a21a2ca30fd69230750b8cf8aa2ae481b97a16531b47b4
sha512=c946cd1ac014726f4d21791e14d806a205680e6edfa2f80ed8d3680f24f48ca3c5a2f89d5afa68c11eac4053ead448b6381fb3d06dc8ff129097af6c69b262fb
doc/modelkit/Modelkit/Cross_validation/index.html
Module Modelkit.Cross_validation
Deterministic cross-validation over immutable pipelines.
Split membership is planned from seed before fitting. Each fold receives a child seed derived from its logical index and fit_seed, which defaults to seed; meta-estimators can therefore vary fit randomness without changing split membership. Training and test partitions are materialized explicitly, so every preprocessing stage is fitted only from training rows. Fold and scorer arrays retain splitter and caller order.
fit_time and score_time are portable process CPU seconds measured with Sys.time; intervals can overlap under parallel execution, so their sum is not elapsed wall time. Abort returns the lowest-index failure; Record retains typed failures in the report and continues with later folds. Models and indices are retained only when requested. execution defaults to Execution.sequential; every backend must return outputs and the lowest-index failure in logical fold order.
Binary_classification scores with Binary_classification_scorer and requires exactly two declared classes for probability scorers. Multiclass_classification scores with Multiclass_classification_scorer, accepts any pipeline that declares two or more distinct classes, and passes the full probability matrix in declared class order to log-loss scorers. Both request predicted labels and probabilities only when a scorer needs them; a pipeline without the requested capability records a typed prediction failure for the fold.
Out-of-fold prediction requires test folds to contain every source row exactly once and restores successful responses to source row order. Classification callers select labels or probabilities. Probabilities use the complete dataset's ascending class order; missing fitted-fold classes receive zero columns, while unknown or duplicate classes are typed compatibility failures.
metadata defaults to Metadata.of_dataset: dataset weights and groups are selected with each fold's exact training/test row views, including inference. An explicit carrier replaces that default without merging; its fields must match the complete dataset's row count. Splitters still use dataset groups and scorers still use dataset weights. Search refit receives the complete carrier. These inputs are never inferred from a previously fitted model.
A supplied callback receives evaluation lifecycle events and is delivered to nested consumers only when their per-method request opts in. Fold events are buffered and dispatched on the caller domain in logical order; see Callback for bounds, cancellation, and failure semantics.
Each task-specific cross_validate accepts built-in scorers plus optional first-class custom_scorers. Names must be nonblank and unique across both arrays. A custom scorer's Capability.prediction is checked against the task before fitting, and its declared sample-weight support is enforced while scoring.
val target_independent_splitter :
(module SPLITTER
with type rng = Rng.t
and type t = 'specification
and type target = unit) ->
'specification ->
'target splitterAdapts a target-independent splitter such as K_fold.
val target_aware_splitter :
(module SPLITTER
with type rng = Rng.t
and type t = 'specification
and type target = 'target) ->
'specification ->
'target splitterAdapts a target-aware splitter such as Stratified_k_fold.
val successful_fold_count : 'model report -> intval prediction_folds :
'prediction prediction_report ->
'prediction prediction_fold arrayval successful_prediction_fold_count : 'prediction prediction_report -> intval out_of_fold_predictions :
'prediction prediction_report ->
('prediction, failure array) resultReturns predictions restored to source row order. Under Record, any failed folds make the assembled value unavailable; their successful peers remain inspectable through prediction_folds.
module Regression : sig ... endmodule Binary_classification : sig ... endmodule Multiclass_classification : sig ... end