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

Autoemulate.compare: proposed fix for issue #222 #224

Merged
merged 8 commits into from
Aug 9, 2024

Conversation

MaxBalmus
Copy link
Collaborator

No description provided.

Copy link
Contributor

github-actions bot commented Aug 9, 2024

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  tests
  test_compare.py
Project Total  

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

@codecov-commenter
Copy link

codecov-commenter commented Aug 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.19%. Comparing base (2f1d439) to head (e6445e2).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #224      +/-   ##
==========================================
+ Coverage   91.14%   91.19%   +0.05%     
==========================================
  Files          45       45              
  Lines        2393     2407      +14     
==========================================
+ Hits         2181     2195      +14     
  Misses        212      212              

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

MaxBalmus and others added 2 commits August 9, 2024 11:41
comment re indentation

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@MaxBalmus MaxBalmus requested a review from mastoffel August 9, 2024 10:48
Copy link
Collaborator

@mastoffel mastoffel left a comment

Choose a reason for hiding this comment

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

Thanks for spotting and fixing this @MaxBalmus !

Also, would you mind adding a test for this to test_compare.py ? I think something like this should work:

# --------------- test correct hyperparameter updating ------------------
def test_param_search_updates_models(ae, Xy):
    X, y = Xy
    ae.setup(X, y, model_subset=["RandomForest"], param_search=True,
             param_search_iters=5)
    params_before = ae.models[0].get_params() # just one model, so index with 0
    ae.compare()
    params_after = ae.models[0].get_params()
    assert params_before != params_after

def test_model_params_equal_wo_param_search(ae, Xy):
    X, y = Xy
    ae.setup(X, y, model_subset=["RandomForest"])
    params_before = ae.models[0].get_params()
    ae.compare()
    params_after = ae.models[0].get_params()
    assert params_before == params_after

tests can be run with pytest: pytest tests/test_compare.py::test_param_search_updates_models

autoemulate/compare.py Outdated Show resolved Hide resolved
autoemulate/compare.py Outdated Show resolved Hide resolved
@MaxBalmus
Copy link
Collaborator Author

Silly question: how do I run the tests locally?

@mastoffel
Copy link
Collaborator

Silly question: how do I run the tests locally?

not a silly question! Run them with pytest in the terminal in the AutoEmulate directory:

pytest tests/test_compare.py -> run all tests in the file
pytest tests/test_compare.py::specific_test -> run specific_test in that file
pytest -s tests/test_compare.py -> show print statements in tests

let me know if something doesn't work!

@mastoffel
Copy link
Collaborator

@all-contributors please add @MaxBalmus for code, bug

Copy link
Contributor

@mastoffel

I've put up a pull request to add @MaxBalmus! 🎉

MaxBalmus and others added 3 commits August 9, 2024 14:38
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
params_after = ae.models[0].get_params()
assert params_before != params_after

def test_model_params_equal_wo_param_search(ae, Xy):
Copy link
Contributor

Choose a reason for hiding this comment

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

[blackfmt] reported by reviewdog 🐶

Suggested change
def test_model_params_equal_wo_param_search(ae, Xy):
def test_model_params_equal_wo_param_search(ae, Xy):

params_before = ae.models[0].get_params()
ae.compare()
params_after = ae.models[0].get_params()
assert params_before == params_after
Copy link
Contributor

Choose a reason for hiding this comment

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

[blackfmt] reported by reviewdog 🐶

Suggested change
assert params_before == params_after
assert params_before == params_after

@MaxBalmus MaxBalmus requested a review from mastoffel August 9, 2024 14:06
Copy link
Collaborator

@mastoffel mastoffel left a comment

Choose a reason for hiding this comment

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

looks great!

@mastoffel mastoffel merged commit 5a8e902 into main Aug 9, 2024
6 checks passed
@mastoffel mastoffel deleted the max-fix-hyperparameter-optim branch August 9, 2024 14:22
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.

3 participants