Fix multiclass SVC with non-uniform class weights - #8592
Conversation
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
| mask = (y == class_i) | (y == class_j) | ||
| indices = np.flatnonzero(mask) | ||
| X_binary = X[indices] | ||
| if pairwise: | ||
| X_binary = X_binary[:, indices] | ||
| y_binary = (y[indices] == class_j).astype(np.int32) |
There was a problem hiding this comment.
Following Scikit-Learn's logic over here.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review. 📝 SummarySummary by CodeRabbit
WalkthroughThe change adds weighted One-vs-One and One-vs-Rest fitting, propagates weights through multiclass SVC, prevents class-weight duplication, preserves feature metadata, and adds comparisons with scikit-learn. ChangesWeighted multiclass SVC
Priority: ➖ Normal Estimated code review effort: 4 (Complex) | ~45 minutes Change: Bug fix · Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to Weighted multiclass SVC fitting now propagates weights through the binary estimators and is validated against scikit-learn across the stated strategy and input variants. No merge-blocking risk remains. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Comment |
Fixes #8578.
Multiclass SVC converted class weights into per-sample weights but did not pass them to the binary classifiers. This caused incorrect predictions with non-uniform class weights.
This PR explicitly forwards the correct weights:
Regression tests cover class weights, sample weights, dense and sparse inputs, numeric and string labels, and both multiclass strategies.