Skip to content

Implemented multiclass classification support across the C++ core and both Python wrappers, including fitting, prediction, metrics, simplification, and visualization. - #69

Merged
gAldeia merged 10 commits into
masterfrom
feature/multiclassification
Sep 22, 2026

Conversation

@gAldeia

@gAldeia gAldeia commented Sep 22, 2026

Copy link
Copy Markdown
Collaborator

Multiclass support

  • Implemented stable, row-wise softmax probabilities.
  • Softmax roots now emit one column per class (currently supporting 2–5 classes due to the current signature limit).
  • Implemented multiclass log loss, accuracy, and balanced accuracy.
  • Added sklearn label encoding/restoration for BrushClassifier and DeapClassifier.
  • Added predict_proba support for multiclass programs, individuals, and engines.
  • Added C++ and Python multiclass test coverage.
  • Added multiclassification.ipynb with sklearn data, tree output, and Graphviz rendering.

Fitting and optimization

  • Binary classification now minimizes weighted log loss using sqrt(weight × log_loss) residuals.

  • Class weights are propagated from estimator parameters into fitting while preserving existing unweighted behavior.

  • Multiclass fitting now optimizes float/logit parameters using weighted multinomial log loss.

  • Split thresholds are greedily fitted and refreshed whenever fit() runs:

    • SplitOn fits its decision subtree first.
    • SplitBest refreshes its selected feature and threshold.
    • Boolean branches remain unweighted.
  • Split nodes are excluded from Ceres parameter vectors so their thresholds do not interfere with subsequent float parameters.

  • Corrected regression split gain to use child-size-weighted variance rather than favoring small partitions.

Simplification

Fixed an issue where multiclass constant simplification treated every subtree as matrix-valued. Class-logit branches are vector-valued, so dispatching Sum as matrix-valued could produce Sum(MatrixF) and incorrectly collapse valid branches.

  • Simplifier now evaluates multiclass nodes according to their actual return type.
  • Softmax DOT edges are labeled class 0, class 1, etc.
  • Added regression coverage for multiclass fitting, simplification, and probability prediction.

Validation

  • Python syntax checks passed.
  • Notebook JSON/content validation passed.
  • C++ extension builds successfully using the generated Makefile (CMake is not available on the current shell's PATH).
  • Focused evaluation tests pass.
  • All 16 existing regression optimizer tests pass.
  • Added coverage for weighted binary fitting, multiclass weighted fitting, split-threshold fitting with float-leaf fitting, and multiclass probability prediction.
  • Fixed both previously reported failures:
    • Multiclass fitting no longer attempts to use the scalar-only weight optimizer with an invalid ArrayFJet Softmax callable.
    • predict_proba is now correctly bound for multiclass programs, individuals, and engines.

@gAldeia

gAldeia commented Sep 22, 2026

Copy link
Copy Markdown
Collaborator Author

Looks good. approved

@gAldeia
gAldeia merged commit 1823dfb into master Sep 22, 2026
6 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant