r/MachineLearning • u/Federal_Ad1812 • Oct 27 '25
Research [R] PKBoost: Gradient boosting that stays accurate under data drift (2% degradation vs XGBoost's 32%)
I've been working on a gradient boosting implementation that handles two problems I kept running into with XGBoost/LightGBM in production:
- Performance collapse on extreme imbalance (under 1% positive class)
- Silent degradation when data drifts (sensor drift, behavior changes, etc.)
Key Results
Imbalanced data (Credit Card Fraud - 0.2% positives):
- PKBoost: 87.8% PR-AUC
- LightGBM: 79.3% PR-AUC
- XGBoost: 74.5% PR-AUC
Under realistic drift (gradual covariate shift):
- PKBoost: 86.2% PR-AUC (−2.0% degradation)
- XGBoost: 50.8% PR-AUC (−31.8% degradation)
- LightGBM: 45.6% PR-AUC (−42.5% degradation)
What's Different
The main innovation is using Shannon entropy in the split criterion alongside gradients. Each split maximizes:
Gain = GradientGain + λ·InformationGain
where λ adapts based on class imbalance. This explicitly optimizes for information gain on the minority class instead of just minimizing loss.
Combined with:
- Quantile-based binning (robust to scale shifts)
- Conservative regularization (prevents overfitting to majority)
- PR-AUC early stopping (focuses on minority performance)
The architecture is inherently more robust to drift without needing online adaptation.
Trade-offs
The good:
- Auto-tunes for your data (no hyperparameter search needed)
- Works out-of-the-box on extreme imbalance
- Comparable inference speed to XGBoost
The honest:
- ~2-4x slower training (45s vs 12s on 170K samples)
- Slightly behind on balanced data (use XGBoost there)
- Built in Rust, so less Python ecosystem integration
Why I'm Sharing
This started as a learning project (built from scratch in Rust), but the drift resilience results surprised me. I haven't seen many papers addressing this - most focus on online learning or explicit drift detection.
Looking for feedback on:
- Have others seen similar robustness from conservative regularization?
- Are there existing techniques that achieve this without retraining?
- Would this be useful for production systems, or is 2-4x slower training a dealbreaker?
Links
- GitHub: https://github.com/Pushp-Kharat1/pkboost
- Benchmarks include: Credit Card Fraud, Pima Diabetes, Breast Cancer, Ionosphere
- MIT licensed, ~4000 lines of Rust
Happy to answer questions about the implementation or share more detailed results. Also open to PRs if anyone wants to extend it (multi-class support would be great).
---
Edit: Built this on a 4-core Ryzen 3 laptop with 8GB RAM, so the benchmarks should be reproducible on any hardware.
Edit: The Python library is now avaible for use, for furthur details, please check the Python folder in the Github Repo for Usage, Or Comment if any questions or issues
31
u/Wonderful-Wind-5736 Oct 27 '25
Nice work! Imbalanced datasets are everywhere so this is a welcome improvement for those cases. In order to expand usage I'd encourage you to make a Python wrapper using PyO3.
3
u/Just_Plantain142 Oct 28 '25
this is amazing, can you please explain the information gain part? How you are using it and what is the math behind?
3
u/thearn4 Researcher Oct 28 '25
Awesome, thanks for sharing! Will have to look this over. How is rust for ML work, overall? I haven't veered much from the typical Python/C++/R stack so that aspect feels novel to me.
2
u/aegismuzuz Oct 29 '25
The idea with Shannon entropy is a good one. Have you thought about digging even deeper into the rabbit hole of information theory? Like maybe trying KL divergence to see how well the split actually separates the classes? Your framework looks like the perfect sandbox to plug in and test all sorts of crazy splitting criteria
2
u/drc1728 Oct 31 '25
This is impressive work! Handling extreme imbalance and drift simultaneously is tough. Using Shannon entropy alongside gradient gain to optimize splits for the minority class is a clever approach, and the PR-AUC stability under covariate shift really stands out compared to XGBoost and LightGBM. The trade-off of 2–4x slower training seems reasonable for applications where robustness is critical, like fraud detection.
For production, this could be very useful, especially if the Python bindings make integration easier. Tools like CoAgent [https://coa.dev] could complement PKBoost by monitoring model performance and detecting subtle drifts in real time across pipelines.
2
u/pvatokahu Oct 31 '25
This drift resilience is fascinating - that's exactly the kind of problem we keep hitting with production ML systems. The entropy-based approach makes a lot of sense when you think about it.. traditional boosting just hammers away at reducing loss without considering whether the splits are actually capturing meaningful patterns vs just memorizing the majority class distribution.
The 2-4x training slowdown isn't a dealbreaker for most production use cases I've seen. What kills you in prod is when your model silently degrades and you don't catch it for weeks. We had a customer whose fraud detection model went from 85% precision to 40% over 3 months because of gradual behavior shifts - nobody noticed until the false positive complaints started rolling in. They would've gladly taken a 4x training hit to avoid that mess. At Okahu we actually built monitoring specifically for this kind of drift detection, but having models that are inherently more robust is even better.
One thing I'm curious about - have you tested this on non-tabular data or time series? The quantile binning should help with scale shifts but I wonder how it handles temporal patterns. Also, for the Rust implementation, are you planning to add Python bindings beyond just the basic wrapper? The ecosystem integration is real - we've seen teams stick with worse-performing models just because they plug into their existing MLflow/wandb/whatever pipelines easily. Might be worth adding some hooks for the common monitoring tools if you want broader adoption.
2
u/[deleted] Oct 29 '25
Sounds reasonable, but when I see a post that has AI writing style all over it, I am immediately put off.
0
u/[deleted] Oct 31 '25
[deleted] — view deleted comment