complete implementation for group based imbalance class
(cherry picked from commit 8ff0085cba09cf13799b9cc280446de50f963a6d)