package modelkit-xgboost
Module Modelkit_xgboost.ClassifierSource
Binary and multiclass CPU histogram-tree classification.
type report = {rounds : int;native_version : int * int * int;native_seed : int64;class_count : int;training_rows : int;effective_rows : int;feature_conversion : Input.report;target_conversion : Input.report;weight_conversion : Input.report option;
}Records original/effective row counts and conversion allocations. Shapes describe the original inputs; retained buffers contain positively weighted rows only. Full-input float32 staging and row-index arrays are reported separately. Mapping tables, class storage, native allocations, and the temporary cache-detachment model buffer are excluded.
A fresh copy of the sorted original integer labels. Only classes with positive sample weight enter the fitted vocabulary. Labels are mapped to contiguous native indices, preserving values beyond float32 precision.
Specifications are created with Specification.create. At least two positively weighted classes are required; empty, single-class, and single-effective-class targets return typed validation errors. Two effective classes use binary logistic loss; three or more use multiclass softmax cross-entropy. Class count is bounded by exact float32 index representation. Zero-weight rows are removed before native training; numeric admission still validates their features. Native feature NaNs remain missing values.
Prediction returns original labels in row order. Probability ties select the lowest label, including the binary probability-0.5 tie. Schema, native lifetime, concurrency, version-dependent reproducibility, and thread contracts match Regressor. Empty prediction batches are supported.
include Modelkit.CLASSIFIER
with type t := t
and type params := params
and type fitted := fitted
and type rng = Modelkit.Rng.t
include Modelkit.ESTIMATOR
with type target = Modelkit.Target.classification Modelkit.Target.t
and type prediction = Modelkit.Target.classification Modelkit.Target.t
with type t := t
with type params := params
with type fitted := fitted
with type rng = Modelkit.Rng.t
val fit :
t ->
?sample_weight:Modelkit.Sample_weight.t ->
rng:rng ->
feature_schema:Modelkit.Feature_schema.t ->
x:Modelkit.Matrix.t ->
y:target ->
unit ->
(fitted, Modelkit.Error.t) resultval predict :
fitted ->
feature_schema:Modelkit.Feature_schema.t ->
x:Modelkit.Matrix.t ->
(prediction, Modelkit.Error.t) resultval predict_proba :
fitted ->
feature_schema:Modelkit.Feature_schema.t ->
x:Modelkit.Matrix.t ->
(Modelkit.Matrix.t, Modelkit.Error.t) resultFinite float64 probabilities with one column per entry in classes. Binary columns are one-minus-positive-probability and positive probability for the lower and higher labels. Multiclass output is checked to sum to one within 1e-6, then normalized in float64 to remove float32 roundoff. Invalid native probabilities are typed numerical failures.
val predict_proba_with_report :
fitted ->
feature_schema:Modelkit.Feature_schema.t ->
x:Modelkit.Matrix.t ->
(Modelkit.Matrix.t * Input.report, Modelkit.Error.t) resultIncludes the float32 feature-conversion report. Native output buffers and returned probabilities are excluded from that report.
val estimator :
?name:string ->
t ->
((Modelkit.Target.classification Modelkit.Target.t,
Modelkit.Target.classification Modelkit.Target.t)
Modelkit.Pipeline.estimator,
Modelkit.Error.t)
resultPublic estimator packaging with class/probability dispatch, sample-weight routing, package/version provenance, and automatic native serialization attachment. Codec-supported preprocessing persists with the estimator. Loading selects Artifact.classification_codec explicitly; original class order and probability alignment are preserved.