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

Fixed error caused by incorrect call to common_metrics in validation step #105

Merged
merged 3 commits into from
Dec 21, 2023

Conversation

confusedmatrix
Copy link
Contributor

Pull Request

Description

This PR fixes a typo in a parameter name when calling common_metrics in the validation step during training of PVNet. Additionally, as common_metrics expects np.ndarrays as input, the input predictions and target values are cast from torch Tensors to np.ndarrays.

This PR works in conjunction with openclimatefix/ocf-ml-metrics#13 to provide correct logging of validation metrics during training using multiple forecast horizons.

How Has This Been Tested?

Tested by training locally over pre-made data batches

  • Yes

If your changes affect data processing, have you plotted any changes? i.e. have you done a quick sanity check?

  • Yes

Checklist:

  • My code follows OCF's coding style guidelines
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked my code and corrected any misspellings

Copy link

codecov bot commented Dec 13, 2023

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (d0a80ee) 50.85% compared to head (b341182) 50.85%.
Report is 8 commits behind head on main.

Files Patch % Lines
pvnet/models/base_model.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #105   +/-   ##
=======================================
  Coverage   50.85%   50.85%           
=======================================
  Files          26       26           
  Lines        1701     1701           
=======================================
  Hits          865      865           
  Misses        836      836           

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

@confusedmatrix confusedmatrix changed the title Fixed error caused by incorrent call to common_metrics in validation step Fixed error caused by incorrect call to common_metrics in validation step Dec 14, 2023
@peterdudfield
Copy link
Contributor

@dfulu this looks good to go?

@dfulu dfulu self-requested a review December 20, 2023 11:42
Copy link
Member

@dfulu dfulu left a comment

Choose a reason for hiding this comment

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

If I'm correct I think that common_metrics returns scalar values for the rmse and mae. mse_each_step is expected to be an array of mse values for each forecast step. Same with mae_each_step. So I think there is still some work to do to fix this

@peterdudfield
Copy link
Contributor

If I'm correct I think that common_metrics returns scalar values for the rmse and mae. mse_each_step is expected to be an array of mse values for each forecast step. Same with mae_each_step. So I think there is still some work to do to fix this

but this is about the inputs?
Also perhaps a test for this would be a good way to check this?

@confusedmatrix
Copy link
Contributor Author

If I'm correct I think that common_metrics returns scalar values for the rmse and mae. mse_each_step is expected to be an array of mse values for each forecast step. Same with mae_each_step. So I think there is still some work to do to fix this

but this is about the inputs? Also perhaps a test for this would be a good way to check this?

Yep - the PR in ocf-ml-metrics (here: openclimatefix/ocf-ml-metrics#13) updates the common_metrics function to handle scalar and array return types + includes tests for both cases

@dfulu
Copy link
Member

dfulu commented Dec 20, 2023

Thanks @confusedmatrix, I merged your changes to ocf-ml-metrics, so once the build and pip release is done we should update the requirements here and that should be it.

Also @peterdudfield we probably should have a full end2end test for the PVNet training, loop, but I'd say lets do that in a separate issue

@peterdudfield
Copy link
Contributor

Thanks @confusedmatrix, I merged your changes to ocf-ml-metrics, so once the build and pip release is done we should update the requirements here and that should be it.

Also @peterdudfield we probably should have a full end2end test for the PVNet training, loop, but I'd say lets do that in a separate issue

I agree, year put that in a different issue

Copy link
Member

@dfulu dfulu left a comment

Choose a reason for hiding this comment

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

ocf-ml-metrics 0.0.11 has been release so I think this is good to go now

@dfulu dfulu merged commit 195841f into main Dec 21, 2023
4 of 5 checks passed
@peterdudfield peterdudfield deleted the chris/validation-step-error branch February 6, 2024 09:59
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.

Validation step of PVNet training - error in RMSE/MAE loss calculation
3 participants