阈值检测器¶
基于用户给定阈值检测异常的检测器。此检测器将时间序列值与用户给定的阈值进行比较,当值超出阈值时,将时间点识别为异常。
- class darts.ad.detectors.threshold_detector.ThresholdDetector(low_threshold=None, high_threshold=None)[source]¶
基类:
Detector
,_BoundedDetectorMixin
阈值检测器
标记低于或高于 low_threshold 和 high_threshold 的值。
如果为 low_threshold 或 high_threshold 提供单个值,该值将用于序列的所有分量。
如果为参数 low_threshold 和/或 high_threshold 提供值序列,它们的长度必须相同,与传递给 detect() 的序列的维度匹配,或者长度为 1。在后一种情况下,该单个值将用于序列的所有分量。
如果 low_threshold 或 high_threshold 为 None,则不会使用相应的边界。但是,两者中至少一个必须设置。
- 参数
low_threshold (
Union
[int
,float
,Sequence
[float
],None
]) – (序列形式的) 下边界。如果是序列,其维度必须与应用此检测器的序列维度匹配。high_threshold (
Union
[int
,float
,Sequence
[float
],None
]) – (序列形式的) 上边界。如果是序列,其维度必须与应用此检测器的序列维度匹配。
属性
high_threshold
low_threshold
方法
detect
(series[, name]) 检测给定时间序列上的异常。检测给定时间序列上的异常。
eval_metric
(anomalies, pred_scores[, ...]) 根据真实异常对结果进行评分。根据真实异常对结果进行评分。
- detect(series, name='series')¶
检测给定时间序列上的异常。
- 参数
series (
Union
[TimeSeries
,Sequence
[TimeSeries
]]) – 要检测异常的序列(或序列列表)。name (
str
) – series 的名称。
- 返回
二进制预测(如果被视为异常则为 1,否则为 0)
- 返回类型
Union[TimeSeries, Sequence[TimeSeries]]
- eval_metric(anomalies, pred_scores, window=1, metric='recall')¶
根据真实异常对结果进行评分。
- 参数
anomalies (
Union
[TimeSeries
,Sequence
[TimeSeries
]]) – 真实二元异常序列(或序列列表)(如果是异常则为 1,否则为 0)。pred_scores (
Union
[TimeSeries
,Sequence
[TimeSeries
]]) – 估计的异常评分序列(或序列列表),表示每个大小为 w 的窗口的异常程度。window (
int
) – 整型值,表示 pred_scores 中每个点代表的过去样本数量。metric (
Literal
[‘recall’, ‘precision’, ‘f1’, ‘accuracy’]) – 要使用的度量函数名称。必须是 “recall”, “precision”, “f1”, 和 “accuracy” 之一。默认值:“recall”。
- 返回
每个异常评分的度量结果
- 返回类型
Union[float, Sequence[float], Sequence[Sequence[float]]]
- property high_threshold¶
- property low_threshold¶