Skip to content

Preprocessing kbinsdiscretizeroptions

github-actions[bot] edited this page Sep 23, 2026 · 1 revision

Development build. This page describes main, not a released package. The latest published Lodestar.Preprocessing is 0.1.0 — read its documentation.

HomePreprocessingFeature transforming

KBinsDiscretizerOptions

How KBinsDiscretizer places its bins, and what it emits.

public sealed record KBinsDiscretizerOptions

PropertiesBinCount is how many bins each feature is cut into; scikit-learn's n_bins, default 5. Strategy is where the edges go; strategy, default BinStrategy.Quantile. Encoding is what a transformed row carries; encode, default BinEncoding.OneHot. QuantileMethod is which percentile convention a quantile fit reads; quantile_method, default QuantileMethod.AveragedInvertedCdf.

Example — the percentile convention changes the edges, not merely how they are reached.

using Lodestar.Preprocessing;

double[] six = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0];

var ordinal = new KBinsDiscretizerOptions { BinCount = 3, Encoding = BinEncoding.Ordinal };

KBinsDiscretizer averaged = KBinsDiscretizer.Fit(six, 1, ordinal);
KBinsDiscretizer linear = KBinsDiscretizer.Fit(
    six, 1, ordinal with { QuantileMethod = QuantileMethod.Linear });

double byDefault = averaged.BinEdges[0][1];   // => 2.5
double byLinear = linear.BinEdges[0][1];      // => 2.666666666666667

Remarks — AveragedInvertedCdf is the default because it is the reference's, since scikit-learn 1.9 deprecated leaving the convention unstated. Linear is numpy's own default and what the reference used before; a caller comparing against an older pipeline wants it, and a caller starting here does not.

subsample is absent, as it is on QuantileTransformer, and for the same reason: the reference draws it from numpy's generator, so an unseeded default cannot be frozen into a corpus.

random_state is absent with it — it exists there only to seed that subsample and the kmeans initialisation, and BinStrategy.KMeans here starts from the uniform bin midpoints, which is deterministic.

Being a record, two option sets with the same four values are equal, and with copies one.

Applies to — net10.0, netstandard2.0.

See alsoKBinsDiscretizer.Fit, BinStrategy, QuantileMethod.

Clone this wiki locally