Update 03-ad.md

This commit is contained in:
Haojun Liao 2024-12-16 17:08:25 +08:00 committed by GitHub
parent 5ff10141f5
commit fd84901702
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 3 deletions

View File

@ -15,7 +15,6 @@ sidebar_label: "异常检测"
下面我们开发一个示例异常检测算法,在异常检测中,将输入时间序列值的最后一个值设置为异常值,并返回结果。 下面我们开发一个示例异常检测算法,在异常检测中,将输入时间序列值的最后一个值设置为异常值,并返回结果。
```python ```python
import numpy as np
from taosanalytics.service import AbstractAnomalyDetectionService from taosanalytics.service import AbstractAnomalyDetectionService
# 算法实现类名称 需要以下划线 "_" 开始,并以 Service 结束 # 算法实现类名称 需要以下划线 "_" 开始,并以 Service 结束
@ -33,7 +32,7 @@ class _MyAnomalyDetectionService(AbstractAnomalyDetectionService):
super().__init__() super().__init__()
def execute(self): def execute(self):
""" 算法逻辑的核心实现""" """ 算法逻辑的核心实现"""
"""创建一个长度为 len(self.list),全部值为 1 的结果数组,然后将最后一个值设置为 -1表示最后一个值是异常值""" """创建一个长度为 len(self.list),全部值为 1 的结果数组,然后将最后一个值设置为 -1表示最后一个值是异常值"""
res = [1] * len(self.list) res = [1] * len(self.list)
@ -44,7 +43,7 @@ class _MyAnomalyDetectionService(AbstractAnomalyDetectionService):
def set_params(self, params): def set_params(self, params):
"""该算法无需任何输入参数,直接重载父类该函数,不处理算法参数设置逻辑""" """该算法无需任何输入参数,直接重载父类该函数,不处理算法参数设置逻辑"""
pass pass
``` ```