Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement pluggable classifiers for RESSPECT #45

Merged
merged 6 commits into from
Oct 16, 2024

Conversation

drewoldag
Copy link
Collaborator

@drewoldag drewoldag commented Oct 14, 2024

This PR represents the work to implement a pluggable system for classifiers.

From the users perspective, the API hasn't changed. To specify a classifier, define a LoopConfiguration instance with the classifier value set to one of the preexisting models: "RandomForest", "KNN", "MLP", "SVM", "NBG".

To make use of a classifier defined outside of Resspect, set the classifier value in the LoopConfiguration instance to be the import specification for the external classifier: "external_package.sub_module.ClassifierClassName".

The externally defined classifier will need to inherit from ResspectClassifier like so:

from resspect.classifiers import ResspectClassifier

class ExternalClassifer(ResspectClassifier):
    def __init__(self, train_data, train_labels, test_data, **kwargs):
        super().__init__(train_features, train_labels, test_features, **kwargs)
        self.clf = <The external classifier definition>
  • Includes a base ResspectClassifier class and early RandomForest class
  • Small edit to ReFitVotingClassifier default parameters
  • Implemented RandomForestClassifier as first subclass of ResspectClassifier
  • Basic plugin system working that will generate a dictionary of {<class_name>: } that can be used to create a particular class instance at runtime.
  • Plugin system also supports loading external subclasses ResspectClassifier by using the import specification string, module.submodule.class_name.
  • Implemented ResspectClassifier subclasses for all other built-in classifiers
  • Removed if/else ladder code from database.py that is now redundant.
  • Added tests for coverage of the plugin system

@drewoldag drewoldag self-assigned this Oct 14, 2024
@drewoldag drewoldag marked this pull request as draft October 14, 2024 23:14
Copy link

github-actions bot commented Oct 14, 2024

Before [a5c71dd] After [d5ffa21] Ratio Benchmark (Parameter)
165±0.7ms 169±3ms 1.02 benchmarks.time_learn_loop('KNN', 'UncSampling')
134±2ms 136±1ms 1.01 benchmarks.time_feature_creation
163±0.5ms 164±2ms 1.01 benchmarks.time_learn_loop('KNN', 'RandomSampling')
173M 173M 1 benchmarks.peakmem_learn_loop('KNN')
169M 169M 1 benchmarks.peakmem_learn_loop('RandomForest')
2.59±0.03s 2.56±0.01s 0.99 benchmarks.time_learn_loop('RandomForest', 'RandomSampling')
2.63±0.03s 2.60±0.02s 0.99 benchmarks.time_learn_loop('RandomForest', 'UncSampling')

Click here to view all benchmarks.

…place. Need to create the other built-in classifer classes still.
@drewoldag drewoldag marked this pull request as ready for review October 16, 2024 19:58
@drewoldag drewoldag requested a review from maxwest-uw October 16, 2024 20:57
@drewoldag drewoldag merged commit 4e130d1 into main Oct 16, 2024
7 checks passed
@drewoldag drewoldag deleted the issue/32/scaffolding-for-pluggable-classifiers branch October 16, 2024 21:21
@drewoldag drewoldag linked an issue Oct 16, 2024 that may be closed by this pull request
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.

Scaffolding for pluggable components
3 participants