Skip to content

Conversation

@gavinevans
Copy link

Addresses metoppv#2135

Description
This PR includes modifications following the review comments in metoppv#2135. Some additional changes have also been made, for example, adding support for dynamic features and the use of a coordinate other than wmo_id to uniquely identify each site.

Note that to help with avoiding duplication, the split_pickle_parquet_and_netcdf and identify_parquet_type functions, and the pickle file handling from improver/cli/__init__.py has been copied metoppv#2153.

Testing:

  • Ran tests and they passed OK
  • Added new tests for the new feature(s)

@codecov-commenter
Copy link

codecov-commenter commented Sep 17, 2025

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 13.33333% with 195 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (mobt_877_implement_qrf@3948062). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...oad_and_train_quantile_regression_random_forest.py 16.04% 68 Missing ⚠️
...r/calibration/quantile_regression_random_forest.py 4.91% 58 Missing ⚠️
improver/calibration/__init__.py 20.00% 36 Missing ⚠️
...oad_and_apply_quantile_regression_random_forest.py 15.00% 17 Missing ⚠️
improver/utilities/compare.py 0.00% 16 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@                    Coverage Diff                    @@
##             mobt_877_implement_qrf      #17   +/-   ##
=========================================================
  Coverage                          ?   95.71%           
=========================================================
  Files                             ?      142           
  Lines                             ?    14158           
  Branches                          ?        0           
=========================================================
  Hits                              ?    13551           
  Misses                            ?      607           
  Partials                          ?        0           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

to draw from the total number of samples available to train each tree.
If None, then each tree contains the same number of samples as the total
available. The trees will therefore only differ due to the use of
bootstrapping (i.e. sampling with replacement) when creating the
Copy link
Owner

Choose a reason for hiding this comment

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

Typo here with "the each tree".

Copy link
Author

Choose a reason for hiding this comment

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

I've corrected this typo.

Returns:
None:
The function creates a pickle file.
A quantile regression random forest model.
Copy link
Owner

Choose a reason for hiding this comment

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

Should we not still call it a pickle file so the user can identify the file type they're looking for?

Copy link
Author

Choose a reason for hiding this comment

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

I've extended this docstring.


class LoadAndApplyQRF(PostProcessingPlugin):
class PrepareAndApplyQRF(PostProcessingPlugin):
"""Load and apply the trained Quantile Regression Random Forest (QRF) model."""
Copy link
Owner

Choose a reason for hiding this comment

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

This docstring wants updating now we've changed the name

Copy link
Author

Choose a reason for hiding this comment

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

I've amended the docstring.

cube_inputs: List of cubes containing the features and the forecast to be
calibrated.
qrf_descriptors: The trained QRF model to be applied to the forecast
and the transformation and pre-transform addition applied during
Copy link
Owner

Choose a reason for hiding this comment

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

I think this should include what's in the comment below about what's expected, e.g. Descriptors expected: (qrf_model, transformation, pre_transform_addition)

Copy link
Author

Choose a reason for hiding this comment

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

Amended docstring.

unique_site_id_keys: Union[list[str], str] = "wmo_id",
):
"""Initialise the LoadAndTrainQRF plugin."""
"""Initialise the LoadForQRF plugin.
Copy link
Owner

Choose a reason for hiding this comment

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

Should this be LoadForTrainQRF?

Copy link
Author

Choose a reason for hiding this comment

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

Corrected.

pre_transform_addition (float):
Value to be added before transformation.
calibrated e.g. air_temperature. This will be used to separate it from
the rest of the feature cubes, if present.
Copy link
Owner

Choose a reason for hiding this comment

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

I think this is missing the name of the argument: unique_site_id_keys (list):

Copy link
Author

Choose a reason for hiding this comment

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

Added missing argument to docstring.

raise IOError(err)
# if recreate_file_path == kgo_path:
# err = (
# f"Recreate KGO path {recreate_file_path} must be different from"
Copy link
Owner

Choose a reason for hiding this comment

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

Is this something that is intended to be committed?

Copy link
Author

Choose a reason for hiding this comment

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

I've reverted this.

@Kat-90 Kat-90 merged commit cecd99e into Kat-90:mobt_877_implement_qrf Sep 22, 2025
5 checks passed
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