nci / scores

scores: metrics for the verification, evaluation and optimisation of forecasts, predictions or models
https://scores.readthedocs.io/
Apache License 2.0
25 stars 9 forks source link

Cyclic block bootstrapping alternate version #522

Open nikeethr opened 3 weeks ago

nikeethr commented 3 weeks ago

I would like the following data processing tool to be considered for addition to the scores repository

I want to add an https://github.com/nci/scores/labels/emerging version of the block bootstrapping.

A common implementation used scientific users, from the xbootstrap package. An initial review of the code (albeit by myself) found that while the functionally seems to be correct, it has some things I'm unsure about/are hard to verify, which are explained in #418. Shaping it to conform to the coding standards in scores can be tricky due to the reliance of multiple coding paradigms in the original implementation.

Furthermore, any updates/bugs/api incompatibilities related to the original implementation will have to be tracked and ported across.

I think it may be good to have a "in-house"/redesigned version. This version would be more in line with our code design paradigms, and hopefully improve maintainability and extension.

Please provide a reference data processing tool

See:

[!NOTE] The concept of bootstrapping isn't in itself that hard. It basically involves sampling a block of data per iteration rather than a single point and reshaping it to fit the original dataset, potentially stacked over several iterations. This is done to address cross-correlations between samples affecting various statistical estimators e.g. mae.

This is easily available in (in-built?) R packages. The trickiness comes from having to deal with arbitrary number of axes (nd-arrays) efficiently, and block sizes that don't fill the nd-axes tightly. The solution is actually fairly straightforward with recursive algorithms/functional programming, but things can become verbose in an iterative implementation.

There are several tricks that can be used to overcome this, so I would suggest an initial implementation be in the https://github.com/nci/scores/labels/emerging space

nikeethr commented 3 weeks ago

From a pedantic view, "cyclic" permutation makes more sense than "circular" from a mathematical standpoint, and in an implementation context. Indices can be cyclic, not circular - which tends to be more of a geometric nomenclature. Though admittedly "circular" is what some reference papers use (in the context of atmospheric science.).

I think it's dependent on the target user, but I prefer cyclic.

I can see it being used in a general context as well e.g. in machine learning.