Modelkit.Class_weightClass-weight specifications resolved into per-row sample weights.
Balanced weights every class by total / (classes * class_total) over weighted class frequencies, so rarer classes receive larger weights and the weighted total is preserved. Explicit assigns listed labels their weight and every other label one. Resolution multiplies the class weight into the supplied sample weight, or into one when no sample weight is given; rows with zero weight stay zero and classes with no positive weight are absent from Class_weight.class_weights. Labels listed by Explicit but absent from the rows are ignored rather than rejected, so fold-local training subsets that miss a rare class still resolve.
Pipeline.classifier resolves a class weight on each fit's own rows, which keeps balanced weights fold-local under cross-validation. Resolution is O(rows) time and space.
val balanced : tValidates distinct labels and finite non-negative weights.
val class_weights :
t ->
?sample_weight:Sample_weight.t ->
Target.classification Target.t ->
((int * float) array, Error.t) resultReturns the effective weight of each positively weighted class in ascending label order.
val resolve :
t ->
?sample_weight:Sample_weight.t ->
Target.classification Target.t ->
(Sample_weight.t, Error.t) result