package modelkit

  1. Overview
  2. Docs
Portable classical machine learning workflows for OCaml

Install

dune-project
 Dependency

Authors

Maintainers

Sources

modelkit-0.5.0.tbz
sha256=1fe8fa7c7f904dd098a21a2ca30fd69230750b8cf8aa2ae481b97a16531b47b4
sha512=c946cd1ac014726f4d21791e14d806a205680e6edfa2f80ed8d3680f24f48ca3c5a2f89d5afa68c11eac4053ead448b6381fb3d06dc8ff129097af6c69b262fb

doc/modelkit/Modelkit/Class_weight/index.html

Module Modelkit.Class_weight

Class-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.

type t =
  1. | Balanced
  2. | Explicit of (int * float) array
val balanced : t
val explicit : (int * float) list -> (t, Error.t) result

Validates 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) result

Returns the effective weight of each positively weighted class in ascending label order.