package modelkit

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Modelkit.One_hot_encoder

Encoding of finite float64 categories as dense or CSR indicator columns.

Categories are learned independently per feature and sorted ascending. Output columns follow input-feature order, then category order. Reject reports a category absent during fitting; Ignore emits an all-zero group for that feature. max_output_features bounds the fitted output width, and sample weights are rejected.

type unknown_category =
  1. | Reject
  2. | Ignore
type params = {
  1. unknown_category : unknown_category;
  2. max_output_features : int;
}
type t
type fitted
val create : ?unknown_category:unknown_category -> ?max_output_features:int -> unit -> (t, Error.t) result
val categories : fitted -> Vector.t array
val transform_csr : fitted -> feature_schema:Feature_schema.t -> x:Matrix.t -> (Csr_matrix.t, Error.t) result

Applies the fitted encoder directly into canonical checked CSR storage without allocating the equivalent dense indicator matrix.

include TRANSFORMER with type t := t and type params := params and type target = unit and type fitted := fitted and type rng = Rng.t
include SPECIFICATION with type t := t with type params := params
val clone : t -> t
val params : t -> params
type target = unit
type rng = Rng.t
val fit : t -> ?sample_weight:Sample_weight.t -> rng:rng -> feature_schema:Feature_schema.t -> x:Matrix.t -> y:target option -> unit -> (fitted, Error.t) result
val transform : fitted -> feature_schema:Feature_schema.t -> x:Matrix.t -> (Matrix.t, Error.t) result
val fitted_params : fitted -> params
val input_schema : fitted -> Feature_schema.t
val output_schema : fitted -> Feature_schema.t