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

Add gpytorch.metrics and tests #1870

Merged
merged 37 commits into from
Mar 8, 2022
Merged

Conversation

patel-zeel
Copy link
Contributor

@patel-zeel patel-zeel commented Dec 23, 2021

As discussed in #1857 with @gpleiss.

Added the following workflows with tests

  • gpytorch.metrics.coverage_error
  • gpytorch.metrics.mean_standardized_log_loss
  • gpytorch.metrics.negatave_log_predictive_density

Initially, I thought of the following version:
metric(model, likelihood, test_x, test_y)

But, I had to drop the idea due to the following reason:

  • Prediction strategy may differ for each model using model and likelihood. For example, use of gpytorch.settings.fast_pred_var() may not be desired for all models.

Thus, currently, we have the following version suitable for all models:
metric(pred_dist, test_y)

Please let me know if corrections/improvements are required.

@patel-zeel
Copy link
Contributor Author

  • Renamed coverage_error to percentile_coverage_error which takes an argument percentile in range [0, 100]. default is 95.
  • Added average_coverage_error with default n_bins to 20.
  • Added tests for average_coverage_error.

@patel-zeel patel-zeel requested a review from wjmaddox February 5, 2022 08:37
gpytorch/metrics/metrics.py Outdated Show resolved Hide resolved
gpytorch/metrics/metrics.py Outdated Show resolved Hide resolved
gpytorch/metrics/metrics.py Outdated Show resolved Hide resolved
gpytorch/metrics/metrics.py Outdated Show resolved Hide resolved

model.train()
likelihood.train()
for i in range(50):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Will this pass if it's 2-3 steps (or even 1)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All metrics except quantile_coverage_error are passing step=1. Currently, I reduced 50 to 20.

Copy link
Collaborator

@wjmaddox wjmaddox Feb 8, 2022

Choose a reason for hiding this comment

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

Will this work at 5 or 10 steps? Lower is better so the unit tests for these don't take a really long time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done @wjmaddox.

@patel-zeel patel-zeel requested a review from wjmaddox February 6, 2022 13:39
@wjmaddox
Copy link
Collaborator

wjmaddox commented Feb 8, 2022

This looks pretty much ready other than the nit above. Do you mind adding a notebook describing the usage to 00_Basic_Usage?

@patel-zeel
Copy link
Contributor Author

Sure @wjmaddox! I welcome your suggestions on the notebook.

@patel-zeel
Copy link
Contributor Author

@wjmaddox I have added the metrics and additional tests. I have also added the entries in Metrics.ipynb. For some reason, 50% of the time, tests were failing on my local system while keeping N_PTS=10 and the number of epochs=5. To summarize:

  • Added mean_squared_error and mean_absolute_error and their tests.
  • Added batch_y testing using MultiTaskGP example.

@patel-zeel patel-zeel requested a review from wjmaddox February 24, 2022 10:11
Copy link
Collaborator

@wjmaddox wjmaddox left a comment

Choose a reason for hiding this comment

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

I realized I should have taken a deeper look before now. But, these should be all that we need to address (modulo checking for an assert error in the quantile function).

test/metrics/test_metrics.py Show resolved Hide resolved
gpytorch/metrics/metrics.py Show resolved Hide resolved
gpytorch/metrics/metrics.py Outdated Show resolved Hide resolved
@patel-zeel
Copy link
Contributor Author

patel-zeel commented Mar 6, 2022

Thanks a lot for your help in resolving the issues @wjmaddox.

modulo checking for an assert error in the quantile function

Is this something that still needs to be addressed? If so, can you please elaborate a bit?

@wjmaddox
Copy link
Collaborator

wjmaddox commented Mar 8, 2022

By that I mean putting a unit test to ensure that the error is raised when we think it does. I'll go ahead and do it.

@patel-zeel
Copy link
Contributor Author

Great! Thank you @wjmaddox

@wjmaddox
Copy link
Collaborator

wjmaddox commented Mar 8, 2022

Sorry about the linting disasters previously.

@wjmaddox
Copy link
Collaborator

wjmaddox commented Mar 8, 2022

ugh, sorry @patel-zeel can you fix the lint, this is pretty much impossible to do in browser mode. hopefully I didnt break the docs somehow with that commit.

@patel-zeel
Copy link
Contributor Author

patel-zeel commented Mar 8, 2022

Done, @wjmaddox. It seems that everything is working fine.

@wjmaddox wjmaddox merged commit aa0ff73 into cornellius-gp:master Mar 8, 2022
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.

2 participants