feat(nn): [#230] Add MLPClassifier and MLPRegressor models#240
Open
vaishnavidesai09 wants to merge 2 commits into
Open
feat(nn): [#230] Add MLPClassifier and MLPRegressor models#240vaishnavidesai09 wants to merge 2 commits into
vaishnavidesai09 wants to merge 2 commits into
Conversation
Author
|
Hi @blkdmr pls review this pr let me know if changes required |
Contributor
|
Hey @vaishnavidesai09 ! Thx 4 your effort! Kindly check why |
Author
|
@ApusBerliozi review it pls |
ApusBerliozi
approved these changes
Jul 9, 2026
ApusBerliozi
left a comment
Contributor
There was a problem hiding this comment.
Looks fine by me
@blkdmr, gotta wait for your response, because I can't really check by now whether ML side was done correctly
Contributor
|
@vaishnavidesai09, meanwhile, you can correct one small issue with ruff that shows in pre-commit |
6f8e5bb to
1dc1980
Compare
Author
|
@blkdmr pls review this |
Contributor
Alessio is currently finishing his mater's degree, so I guess he will respond to you at monday or smth |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
MLPClassifierandMLPRegressorunderfenn.nn.models.mlp, givingusers a scikit-learn-style API to train basic MLPs without writing Torch
code. Both estimators build a
torch.nn.Sequentialinternally and delegateall training to the existing
ClassificationTrainer/RegressionTrainer—no training-loop code added.
API
MLPClassifier(hidden_layer_sizes, activation, solver, learning_rate_init, batch_size, max_iter, early_stopping, n_iter_no_change, validation_fraction, device)—.fit(X, y),.predict(X),.predict_proba(X),.score(X, y). Handles binary and multi-class;labels don't need pre-encoding.
MLPRegressor— same constructor,.fit,.predict,.score(R²).fenn.nn.modelsandfenn.nn.Known issue found while testing
ClassificationTrainer.fit()'s validation branch doesn't reshape labels to(-1, 1)for binary classification the way the training branch does, soBCEWithLogitsLossbreaks as soon as aval_loaderis passed withnum_classes == 2. I didn't fix it here since this module shouldn't containtraining-loop code — flagged as a test marked
xfailintest_early_stopping_runs(TestMLPClassifierBinary) with a full explanation.Happy to open a separate issue/PR for it if that's preferred.
Testing
20 new unit tests in
tests/unit/nn/test_mlp.py, covering binary/multiclassclassification, regression, string labels,
predict_proba, error handling,and early stopping.
ruff check,ruff format --check, andtyposall pass.Fixes #230