Feature: evaluation granularity#51
Merged
sarusso merged 10 commits intoICSC-Spoke3:developfrom Dec 2, 2025
Merged
Conversation
…es()" This argument has 'data_point' as default
This function evaluates the model with "variable" granularity on a single timeseries
This function evaluates the model with point granularity on a single series
This function evaluates the model with series granularity on a single timeseries
This changes have been made in order to include the parameter granularity in the eveluation
Now in the evaluation on a dataset with only anomalous series the false positives counts are set to zero
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Now it is possible to choose the granularity of the evaluation setting the parameter
granularityin the functionevaluate(). There are 3 possible choices:granularity = 'variable': the detected anomalies of a specific type are counted for each variable of the series (same for false positives). For each series of the dataset, the counts are then divided for a normalization factor, given by the product of the number of variables in the series by its length.Suppose you have series of 2880 data points and 2 variables (temperature and humidity) like this:
there are 5 anomalies, 2 of type 'spike_uv' for the temperature and 3 of type 'step_uv' for the humidity. The model sees both the anomalies on the temperature but only 1 anomaly on the humidity and gives 2 false positives, one on temperature and one on humidity at the same timestamp.
The evaluation of the model on this series will be the following dictionary:
Of course, this granularity can be used on models that assign anomaly flags to each variable of the series
2)
granularity = 'data_point': the detected anomalies of a specific type are counted for each data point of the series. In this case the normalization factor is only the length of the series. For the same example as before, the evaluation result on the series with point granularity will be:The "series_evaluation" dictionary is created for each series of the dataset. To obtain the evaluation on the dataset, values corresponding to the same key are summed.
This is done for each model.
3)
granularity=series: having only one type of anomaly per series is necessary to use this granularity. The anomalous series of the dataset detected as anomalous raise the counts of the type of anomaly. Not anomalous series detected as anomalous raise the counts of false positives.Suppose we have a dataset with 3 normal series and 4 anomalous series with spike_uv, step_uv, pattern_uv and clouds anomalies. The model detects spike_uv and clouds anomalies and gives 1 false positives. The result of the evaluation is:
Values are normalized to the number of series inside the dataset