EventTPR
Event true positive rate, share of true events hit by an alarm.
A true event at time T counts as hit if at least one alarm falls in the window [T + min_offset, T + max_offset]. The score is the number of hit events, divided by the number of true events.
The offsets are signed, negative is before the event and positive is after it. With offsets in the units of X.index, for an event at T:
min_offset=0, max_offset=0: only an alarm exactly atT.min_offset=-3, max_offset=0: advance only, an alarm from 3 beforeTup toT. Late alarms do not count.min_offset=0, max_offset=2: late only, an alarm fromTup to 2 afterT. Early alarms do not count.min_offset=-3, max_offset=2: before and after, an alarm from 3 beforeTup to 2 afterT.min_offset=-10, max_offset=-2: at least 2 beforeT, and not earlier than 10 beforeT. An alarm atTdoes not count.
Positions in y_true and y_pred are iloc references into X, and are mapped through X.index before matching, so X is required. If X has a time index, the offsets are time offsets, for instance pd.Timedelta("-3s"). Otherwise they are in the units of X.index.
One alarm may hit more than one true event, if the event windows overlap.
Only point events are scored, so interval ilocs (segments) in y_true or y_pred raise a ValueError.
If there are no true events, the score is not defined, and nan is returned. If there are true events but no alarms, the score is 0.
Schnellstart
from sktime.performance_metrics.detection import EventTPR
estimator = EventTPR(min_offset=0, max_offset=0)Parameter(2)
- min_offsetint, float, or time offset, default=0
Start of the hit window, relative to the event time
T. Negative values let alarms before the event count. A time offset, for instancepd.Timedelta("-3s"), ifXhas a time index, otherwise a number in the units ofX.index. AValueErroris raised if it is NaN, or aftermax_offset.- max_offsetint, float, or time offset, default=0
End of the hit window, relative to the event time
T. Positive values let alarms after the event count, the default of 0 means that alarms after the event do not count. Same unit asmin_offset. NaN raises aValueError.
Beispiele
>>> import pandas as pd
>>> from sktime.performance_metrics.detection import EventTPR
>>> X = pd. DataFrame ({ "foo": range (10)})
>>> y_true = pd. DataFrame ({ "ilocs": [4, 8 ]})
>>> y_pred = pd. DataFrame ({ "ilocs": [3 ]})
>>> metric = EventTPR (min_offset =- 2)
>>> metric (y_true, y_pred, X) 0.5