[MNT] Refactor CyclicBoosting to eliminate feature validation code duplication#917
Conversation
|
All existing tests pass locally and the refactor preserves the original validation behavior. |
fkiraly
left a comment
There was a problem hiding this comment.
Thanks!
Although, feature validation is not required in the predictmethods, because they are always called after fit - can you remove it from there?
Thanks for the suggestion! That makes sense. I removed the validation calls from the predict methods and kept the Please let me know if anything else should be adjusted. |
|
code quality checks are failing, look at the dev guide or use |
84615a8 to
885fac6
Compare
Done. The CI issue was related to black formatting in test_proba_basic.py. But now its resolved. Please lmk for any further adjustments |
Reference Issues/PRs
Fixes #916
What does this implement/fix? Explain your changes.
This refactoring eliminates code duplication in CyclicBoosting by extracting the repeated feature validation logic into a single helper method _validate_feature_groups(). The change:
Adds helper method _validate_feature_groups(X) that validates all feature groups exist in X columns
Replaces duplicated code in 5 methods with single helper call:
_fit()
_predict()
_predict_proba()
_predict_interval()
_predict_quantiles()
Maintains identical behavior - same error messages and validation logic
Adds a test to ensure missing feature groups raise the expected error.
Does your contribution introduce a new dependency? If yes, which one?
No new dependencies introduced.
What should a reviewer concentrate their feedback on?
Verify that the helper method logic is identical to the original duplicated code
Ensure all 5 methods correctly call the helper method
Check that error messages remain unchanged
Confirm the new test provides adequate coverage
Did you add any tests for the change?
Yes. Added test_cyclic_boosting_missing_feature_validation() to skpro/regression/tests/test_cyclic_boosting.py which:
Tests error messages for missing features
Validates tuple feature groups work correctly
Ensures the helper method is called consistently across all prediction methods
Any other comments?
This is a pure maintenance refactoring that improves code maintainability without changing any external behavior. The fix follows DRY principles and reduces future maintenance burden.
PR checklist
For all contributions
I've added myself to the list of contributors with any new badges I've earned :-)
The PR title starts with [MNT] - maintenance refactoring