bartz.prepcovars.Binner¶
- class bartz.prepcovars.Binner(X, *, key=None)[source]¶
Abstract base class for predictor binners.
A binner inspects the training predictors at construction time, chooses cutpoints for each predictor, and encapsulates the logic that maps any predictor matrix (training or test) to bin indices via
bin.A predictor value
xis mapped to biniiffc[i - 1] < x <= c[i], wherecare the cutpoints chosen for that predictor at construction. A predictor withkcutpoints therefore hask + 1bins indexed from0tok. The number of cutpoints actually used per predictor is exposed asmax_splitand may differ across predictors; the remaining capacity, if any, is padded internally with the maximum value representable in the dtype of the cutpoints, so binning still produces a valid in-range index.The constructor takes the training predictors and an optional random key. Concrete subclasses may add their own keyword arguments. Binners that do not use the key still accept it for protocol uniformity and silently ignore it. Binners that need it raise
ValueErrorif it is not provided.- max_split: AbstractVar[UInt[Array, 'p']]¶
The number of cutpoints actually used for each of the
ppredictors.
- abstractmethod bin(X)[source]¶
Map predictors to bin indices using the cutpoints chosen at construction.
- Parameters:
X (
Real[Array, 'p n']) – A matrix withppredictors andnobservations. Must have the same number of predictors as the training matrix passed to the constructor.- Returns:
UInt[Array, 'p n']– QuantizedXwith minimal data type.