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

Model names #196

Merged
merged 16 commits into from
Mar 3, 2024
Merged

Model names #196

merged 16 commits into from
Mar 3, 2024

Conversation

mastoffel
Copy link
Collaborator

@mastoffel mastoffel commented Feb 29, 2024

  • changes self.models to dict with model_names : model
  • changes get_model_name() to get model name from that dict
  • having two pytorch models with the same class works now

resolves #175 and #190

Copy link
Contributor

github-actions bot commented Feb 29, 2024

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  autoemulate
  compare.py 243
  cross_validate.py 57
  hyperparam_searching.py
  model_processing.py
  printing.py
  save.py 56
  utils.py 91, 97
  autoemulate/emulators
  gaussian_process.py
  gaussian_process_mogp.py 71-83, 87, 90
  gradient_boosting.py
  neural_net_sk.py
  neural_net_torch.py
  polynomials.py
  random_forest.py
  rbf.py
  support_vector_machines.py
  xgboost.py
  autoemulate/emulators/neural_networks
  rbf.py
  tests
  test_cross_validate.py
  test_emulators.py
  test_model_processing.py
  test_printing.py
  test_save.py
  test_torch.py
  test_utils.py
Project Total  

The report is truncated to 25 files out of 29. To see the full report, please visit the workflow summary page.

This report was generated by python-coverage-comment-action

Copy link
Member

@bryanlimy bryanlimy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Have one suggestion for NeuralNetTorch model names.

Also, do you think it would be useful to have a getter function / attribute for all emulators that return the model name? e.g.

> model = NeuralNetTorch(module='mlp')
> model.model_name
NNMLP
> model = RandomForest()
> model.model_name 
RandomForest

"SupportVectorMachines": SupportVectorMachines(),
"XGBoost": XGBoost(),
"NeuralNet": NeuralNetTorch(module="mlp"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we have a prefix of NN followed by <module name> for all NeuralNetTorch model?

e.g.

  • "NNMLP": NeuralNetTorch(module="mlp")
  • "NNRBF": NeuralNetTorch(module="rbf")

so that

  • users can immediately tell they belongs to NeuralNetTorch
  • they will be close to each other when we sort all the model names alphabetically for printing.
  • in pytest, we can test every model that has prefix NN instead of hard-coding their names in our test cases.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this suggestion - what do you think @mastoffel?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

both good suggestions! I'm on it.

@codecov-commenter
Copy link

codecov-commenter commented Mar 1, 2024

Codecov Report

Attention: Patch coverage is 94.77612% with 7 lines in your changes are missing coverage. Please review.

Project coverage is 90.31%. Comparing base (69932f1) to head (8fedada).

Files Patch % Lines
autoemulate/compare.py 85.71% 2 Missing ⚠️
autoemulate/plotting.py 33.33% 2 Missing ⚠️
autoemulate/hyperparam_searching.py 0.00% 1 Missing ⚠️
autoemulate/save.py 87.50% 1 Missing ⚠️
autoemulate/utils.py 87.50% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #196      +/-   ##
==========================================
+ Coverage   88.09%   90.31%   +2.21%     
==========================================
  Files          44       44              
  Lines        2083     2085       +2     
==========================================
+ Hits         1835     1883      +48     
+ Misses        248      202      -46     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kallewesterling
Copy link
Collaborator

LGTM.

Have one suggestion for NeuralNetTorch model names.

Also, do you think it would be useful to have a getter function / attribute for all emulators that return the model name? e.g.

> model = NeuralNetTorch(module='mlp')
> model.model_name
NNMLP
> model = RandomForest()
> model.model_name 
RandomForest

This would be easy to implement through accessing <Class>.__class__.__name__ in a simple implementation like this:

@property
def model_name(self):
    return self.__class__.__name__

...at least I think...?

@bryanlimy
Copy link
Member

bryanlimy commented Mar 1, 2024

LGTM.
Have one suggestion for NeuralNetTorch model names.
Also, do you think it would be useful to have a getter function / attribute for all emulators that return the model name? e.g.

> model = NeuralNetTorch(module='mlp')
> model.model_name
NNMLP
> model = RandomForest()
> model.model_name 
RandomForest

This would be easy to implement through accessing <Class>.__class__.__name__ in a simple implementation like this:

@property
def model_name(self):
    return self.__class__.__name__

...at least I think...?

NeuralNetTorch(module='mlp') and NeuralNetTorch(module='rbf') would have the same name in this case. We can have prefix + module like model_name = f"NN{upper(self.module)}" for all NeuralNetTorch architectures, which will lead to NNMLP, NNRBF etc.

@kallewesterling
Copy link
Collaborator

Sounds like a good solution to me!

@mastoffel
Copy link
Collaborator Author

Ok, implemented both of @bryanlimy's suggestions.

  • Each model now has a model_name property method, and the get_model_name function from utils now retrieves the model name even if the model is wrapped in a Pipeline and Multioutput.
  • Torch model names are now: def model_name(self): return f"NN{self.module_name.capitalize()}"
  • did a few other renames to make things cleaner

@mastoffel
Copy link
Collaborator Author

Maybe would be good if you could quickly have an eye on this too @bryanlimy ! Lots of changes here, but I think it's mostly fine.

@bryanlimy
Copy link
Member

LGTM!

@mastoffel mastoffel merged commit e3ce015 into main Mar 3, 2024
6 checks passed
@mastoffel mastoffel deleted the model-names branch August 12, 2024 14:35
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.

sort out model names
4 participants