EventTPR
EventTPR
- EventTPR(min_offset=0, max_offset=0)[source]
Event true positive rate, share of true events hit by an alarm.
A true event at time
Tcounts 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 atT: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_trueandy_predareilocreferences intoX, and are mapped throughX.indexbefore matching, soXis required. IfXhas a time index, the offsets are time offsets, for instancepd.Timedelta("-3s"). Otherwise they are in the units ofX.index.One alarm may hit more than one true event, if the event windows overlap.
Only point events are scored, so interval
ilocs(segments) iny_trueory_predraise aValueError.If there are no true events, the score is not defined, and
nanis returned. If there are true events but no alarms, the score is 0.- Parameters:
- 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.
Examples
>>> 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

