Skip to main content

Module discretize

Module discretize 

Source
Expand description

KBinsDiscretizer — bin each column of a feature matrix into a small integer alphabet.

Three binning strategies:

  • BinStrategy::Uniform — equal-width bins between the observed min and max.
  • BinStrategy::Quantile — equal-frequency bins from R type-7 quantiles (matches numpy.quantile and preprocessing.KBinsDiscretizer(strategy='quantile')).
  • BinStrategy::KMeans — 1-D KMeans with k-means++ initialisation and deterministic MMIX-LCG seeding, so the resulting bin edges are bit-for-bit reproducible across runs and platforms.

§Output

transform returns a n × d matrix of usize bin indices in [0, n_bins) — the ordinal encoding the reference calls encode='ordinal'. The one-hot encoding is trivially obtained by piping the output through crate::encoders::OneHotEncoder on the resulting numeric- categorical matrix.

Structs§

KBinsDiscretizer
Fitted per-column bin edges.

Enums§

BinStrategy
Binning strategy for KBinsDiscretizer.