Skip to main content

irithyll_core/
feature.rs

1//! Feature type declarations for streaming tree construction.
2
3/// Declares whether a feature is continuous (default) or categorical.
4///
5/// Categorical features are handled differently in the tree construction:
6/// - **Binning:** One bin per observed category value instead of equal-width bins.
7/// - **Split evaluation:** Fisher optimal binary partitioning -- categories are sorted
8///   by gradient\_sum/hessian\_sum ratio, then the best contiguous partition is found
9///   using the same left-to-right XGBoost gain scan.
10/// - **Routing:** Categorical splits use a `u64` bitmask where bit `i` set means
11///   category `i` goes left. This supports up to 64 distinct category values per feature.
12#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
13#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
14pub enum FeatureType {
15    /// Numeric feature split by threshold comparisons (default).
16    #[default]
17    Continuous,
18    /// Categorical feature split by bitmask partitioning.
19    Categorical,
20}