Add return_models option to getPercentScore (#181)#196
Open
OmerJauhar wants to merge 2 commits into
Open
Conversation
…eturn_models=True, the function returns a third value: a list of {model, scaler} dicts, one per CV fold. Default stays False so existing callers are unaffected. The kernel method branch sets scaler to None since it doesn't use one.
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.
Description
Adds an optional
return_models=Falsekeyword togetPercentScore. When set to True, the function returns a third value: a list of{model, scaler}dicts, one per cross-validation fold. Each entry holds the fitted classifier and the StandardScaler that was applied to its training features, so users can run the model on new raw data withscaler.transform(...)followed bymodel.predict(...). The kernel-method branch setsscalertoNonesince that path doesn't use one. Default behavior is unchanged, old callers continue to receive the 2-tuple(c_report_train, c_report_test).Motivation and Context
Closes #181. As @Ignaci09 pointed out,
getPercentScoreonly returned the train and test reports, so there was no way to use the trained models for prediction after cross-validation. Withreturn_models=True, the fitted estimator and its corresponding scaler are now accessible.How has this been tested?
return_models=Truereturns a 3-tuple, withlen(models) == params.k_fold_cv.(model, scaler)pair to runpredict()on unseen samples — output matches expectations.scaler=None(since it doesn't apply a StandardScaler) while still returning the fittedSVC(kernel='precomputed').tests/test_classification.py,tests/test_featureFunctions.py) — 4 passed.make htmlto confirm the new "Extracting the trained models" section renders cleanly with no new Sphinx warningsTypes of changes
Checklist
make clean)make html)pyproject.tomlfile.make tests)