Bucketing¶
bucketing
¶
Stage 2: Bucket construction from decision points.
Given sorted, unique decision points (split thresholds) per feature, constructs a BucketSet with: - A null bucket for missing values (index 0) - Numeric buckets: (-inf, t1), [t1, t2), ..., [tm, inf)
build_buckets
¶
build_buckets(decision_points: ndarray, feature_name: str) -> BucketSet
Construct a BucketSet from sorted decision points for a single feature.
Args: decision_points: Sorted 1-D array of unique split thresholds. feature_name: Name of the feature.
Returns: A BucketSet containing: - Bucket 0: null bucket (for missing values) - Buckets 1..m+1: numeric interval buckets Total: len(decision_points) + 2 buckets.
Source code in src/swift/bucketing.py
build_all_buckets
¶
build_all_buckets(decision_points_dict: dict[str, ndarray]) -> dict[str, BucketSet]
Construct BucketSets for all features.
Args: decision_points_dict: Dict mapping feature name -> sorted decision points.
Returns: Dict mapping feature name -> BucketSet.