package modelkit
Module Modelkit.Artifact
Portable, versioned persistence for fitted built-in pipelines.
Artifacts contain validated data only: no closures, marshalled OCaml values, commands, or training observations are serialized. The container and each component codec are independently versioned. Readers verify a declared MD5 checksum and enforce configurable bounds before allocating component payloads. The checksum detects accidental corruption; it does not authenticate or encrypt an artifact. The current 0.x format is experimental; released readers remain covered by golden compatibility tests.
Pipelines intended for persistence must use the artifact-aware stage and estimator constructors below. Encoding a fitted pipeline containing a component packaged only through Pipeline.transformer or Pipeline.estimator returns a typed artifact error.
type regression_model =
(Target.regression Target.t, Target.regression Target.t) Pipeline.fittedtype binary_classification_model =
(Target.classification Target.t, Target.classification Target.t)
Pipeline.fittedval default_limits : limitsval empty_metadata : metadataval model : 'model loaded -> 'modelval producer_version : _ loaded -> stringval producer_ocaml_version : _ loaded -> string optionval training_rows : metadata -> int optionval sample_weighted : metadata -> bool optionval labels : metadata -> (string * string) arrayval simple_imputer_stage :
name:string ->
Simple_imputer.t ->
(Pipeline.transformer, Error.t) resultval standard_scaler_stage :
name:string ->
Standard_scaler.t ->
(Pipeline.transformer, Error.t) resultval variance_threshold_stage :
name:string ->
Variance_threshold.t ->
(Pipeline.transformer, Error.t) resultval linear_regression_estimator :
name:string ->
Linear_regression.t ->
((Target.regression Target.t, Target.regression Target.t) Pipeline.estimator,
Error.t)
resultval ridge_regression_estimator :
name:string ->
Ridge_regression.t ->
((Target.regression Target.t, Target.regression Target.t) Pipeline.estimator,
Error.t)
resultval logistic_regression_estimator :
name:string ->
Logistic_regression.t ->
((Target.classification Target.t, Target.classification Target.t)
Pipeline.estimator,
Error.t)
resultval encode_regression :
?metadata:metadata ->
?limits:limits ->
regression_model ->
(bytes, Error.t) resultval encode_binary_classification :
?metadata:metadata ->
?limits:limits ->
binary_classification_model ->
(bytes, Error.t) resultval decode_regression :
?limits:limits ->
bytes ->
(regression_model loaded, Error.t) resultval decode_binary_classification :
?limits:limits ->
bytes ->
(binary_classification_model loaded, Error.t) resultval save_regression :
?metadata:metadata ->
?limits:limits ->
path:string ->
regression_model ->
(unit, Error.t) resultEncodes completely before opening path, then writes the destination directly. Atomic replacement, signing, and encryption are transport-level responsibilities.
val save_binary_classification :
?metadata:metadata ->
?limits:limits ->
path:string ->
binary_classification_model ->
(unit, Error.t) resultThe binary-classification counterpart to save_regression.
val load_regression :
?limits:limits ->
path:string ->
unit ->
(regression_model loaded, Error.t) resultval load_binary_classification :
?limits:limits ->
path:string ->
unit ->
(binary_classification_model loaded, Error.t) result