feat(drift): evaluation metrics for drift detectors - #1963
Conversation
Adds river/drift/evaluate.py: detection window matching, the metric functions, a report, and a driver that runs a detector over a stream with known drifts. Targets online-ml#1914. Metric definitions follow Cerqueira et al. 2026 (arXiv:2606.07789) and Bifet 2017 (10.1007/978-3-319-59060-8_64). Code and tests generated with Claude Code, directed and reviewed by me. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Merging this PR will not alter performance
Comparing Footnotes
|
|
For metrics definitions, I used:
|
|
To continue, I want to know: does this belong in river/drift/ or river/evaluate/? |
river/test_docs.py parses the docstring of every public class and function and requires each signature parameter to appear in a Parameters section. The metric functions only had a description and examples, so the parse failed and CI went red on online-ml#1963. Adds Parameters sections to the eleven functions that lacked one, and turns Matching into a typing.NamedTuple so its fields can carry a docstring too. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Thank you for the contribution! If all additions here are metrics, maybe they should go to the
The article from Cerqueira et al. that you mention says that You implementation relies on inputing for x, y in dataset:
y_pred = model.predict_one(x)
metric.update(y, y_pred)
model.learn_one(x, y)Where, at every step, we update the metric with the model's output, so we only need to store the aggregate and not the full output series of the model. This also allows us to get a reading of the metric at any time without additional computation. |
|
Thank you for the reply! Yes, metrics should be in classes not functions, and putting them in Regarding the Regarding the existing metrics, F1, precision, recall can be reused but episode recall counts windows not alarms. NDT and the rest are not classification metrics. To reuse them, I would add a matching step (alarm stream -> drift schedule -> TP/FP/FN under a tolerance window) before reusing the existing arithmetic. Claude also made a mistake with Bifet's paper on how it counts drifts. I will start with the rework shortly. |
Hi, as discussed in #1914, this is a prototype evaluation tool for drift detection at 'river/drift/evaluate.py'. It's only a draft and needs help on the API side.
I used claude code to write the code and tests, while I directed it and reviewed its output before putting it here.
It's my first time contributing here and please let me know what you make of this.