#[non_exhaustive]pub struct FeatureBinner { /* private fields */ }Expand description
Quantile-based feature binner.
Transforms each feature column into u8 bin indices using quantile
boundaries computed during fit(). Missing values (NaN) are
mapped to bin 0; valid values to bins 1–255.
The binning is designed for histogram-based gradient boosting where the O(256) histogram scan replaces the O(n log n) sorted-split search.
Implementations§
Source§impl FeatureBinner
impl FeatureBinner
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new binner with the default 256 max bins.
§Example
use scry_learn::tree::FeatureBinner;
let binner = FeatureBinner::new();Sourcepub fn max_bins(self, bins: usize) -> Self
pub fn max_bins(self, bins: usize) -> Self
Set the maximum number of bins (2..=256, default 256).
Sourcepub fn fit(&mut self, data: &Dataset) -> Result<()>
pub fn fit(&mut self, data: &Dataset) -> Result<()>
Compute bin edges from training data.
For each feature column, sorts the non-NaN values and picks
equally-spaced quantile boundaries to create up to max_bins - 1
valid bins (bin 0 is reserved for missing).
Sourcepub fn transform(&self, data: &Dataset) -> Result<Vec<Vec<u8>>>
pub fn transform(&self, data: &Dataset) -> Result<Vec<Vec<u8>>>
Map features to u8 bin indices.
Returns binned[feature_idx][sample_idx]. NaN → 0, valid → 1..=255.
Sourcepub fn fit_transform(&mut self, data: &Dataset) -> Result<Vec<Vec<u8>>>
pub fn fit_transform(&mut self, data: &Dataset) -> Result<Vec<Vec<u8>>>
Combined fit + transform.
Sourcepub fn n_bins_per_feature(&self) -> &[usize]
pub fn n_bins_per_feature(&self) -> &[usize]
Number of bins per feature (including the missing-value bin).
Trait Implementations§
Source§impl Clone for FeatureBinner
impl Clone for FeatureBinner
Source§fn clone(&self) -> FeatureBinner
fn clone(&self) -> FeatureBinner
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FeatureBinner
impl Debug for FeatureBinner
Auto Trait Implementations§
impl Freeze for FeatureBinner
impl RefUnwindSafe for FeatureBinner
impl Send for FeatureBinner
impl Sync for FeatureBinner
impl Unpin for FeatureBinner
impl UnsafeUnpin for FeatureBinner
impl UnwindSafe for FeatureBinner
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more