Anomaly Detector 项目教程

Anomaly Detector 项目教程

anomalydetector项目地址:https://gitcode.com/gh_mirrors/an/anomalydetector

1. 项目的目录结构及介绍

Anomaly Detector 项目的目录结构如下:

anomalydetector/
├── README.md
├── setup.py
├── anomalydetector/
│   ├── __init__.py
│   ├── client.py
│   ├── models.py
│   ├── operations/
│   │   ├── __init__.py
│   │   ├── anomaly_detection_operations.py
│   │   ├── multivariate_anomaly_detection_operations.py
│   ├── samples/
│   │   ├── sample_detect_entire_series_anomaly.py
│   │   ├── sample_detect_last_point_anomaly.py
│   │   ├── sample_detect_change_point.py
│   │   ├── sample_multivariate_detect.py
│   ├── tests/
│   │   ├── test_client.py
│   │   ├── test_models.py
│   │   ├── test_operations.py
├── docs/
│   ├── conf.py
│   ├── index.rst
│   ├── make.bat
│   ├── Makefile
│   ├── source/
│   │   ├── _static/
│   │   ├── _templates/
│   │   ├── about.rst
│   │   ├── api.rst
│   │   ├── installation.rst
│   │   ├── quickstart.rst
│   │   ├── usage.rst

目录结构介绍

  • anomalydetector/: 项目的主目录,包含主要的代码文件和子目录。
    • __init__.py: 初始化文件,使目录成为一个Python包。
    • client.py: 客户端代码,用于与Anomaly Detector服务进行交互。
    • models.py: 定义了数据模型和请求/响应结构。
    • operations/: 包含各种操作的实现,如异常检测操作。
    • samples/: 包含示例代码,展示如何使用Anomaly Detector API。
    • tests/: 包含测试代码,用于测试项目的各个部分。
  • docs/: 文档目录,包含项目的文档配置和源文件。
    • conf.py: Sphinx文档配置文件。
    • index.rst: 文档的主索引文件。
    • source/: 文档的源文件目录,包含各种文档页面和静态资源。

2. 项目的启动文件介绍

项目的启动文件主要是 client.py,它包含了与Anomaly Detector服务进行交互的客户端代码。以下是 client.py 的主要内容:

from azure.ai.anomalydetector import AnomalyDetectorClient
from azure.ai.anomalydetector.models import *
from azure.common.credentials import ServicePrincipalCredentials

class AnomalyDetector:
    def __init__(self, endpoint, credentials):
        self.client = AnomalyDetectorClient(endpoint, credentials)

    def detect_entire_series_anomaly(self, request):
        return self.client.detect_entire_series_anomaly(request)

    def detect_last_point_anomaly(self, request):
        return self.client.detect_last_point_anomaly(request)

    def detect_change_point(self, request):
        return self.client.detect_change_point(request)

    def detect_multivariate_anomaly(self, request):
        return self.client.detect_multivariate_anomaly(request)

启动文件介绍

  • AnomalyDetectorClient: 这是与Anomaly Detector服务进行交互的主要客户端类。
  • detect_entire_series_anomaly: 用于检测整个时间序列中的异常。
  • detect_last_point_anomaly: 用于检测最新数据点的异常。
  • detect_change_point: 用于检测时间序列中的变化点。
  • detect_multivariate_anomaly: 用于检测多变量时间序列中的异常。

3. 项目的配置文件介绍

项目的配置文件主要是 setup.pydocs/conf.py

setup.py

setup.py 文件用于项目的打包和分发,以下是 setup.py 的主要内容:

from setuptools import setup, find_packages

anomalydetector项目地址:https://gitcode.com/gh_mirrors/an/anomalydetector

  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
Anomaly Transformer是一种基于变压器的异常检测模型,它使用自适应和对抗训练过程。该模型的架构使其能够快速训练和测试,并且能够处理大输入序列。与简单的基于变压器的编码器-解码器网络相比,Anomaly Transformer通过一种对抗性训练程序来缓解重建误差,从而更好地检测异常。\[2\] 在Anomaly Transformer的代码中,可以看到使用了一种名为EncoderAtt的编码器。在该编码器中,通过将原来的.cuda()替换为.to(device),将模型移动到指定的设备上进行训练和推断。具体来说,self.encoder = EncoderAtt(input_size=self.X.shape\[1\], hidden_size=encoder_hidden_size, T=T).to(device)这行代码将EncoderAtt模型移动到指定的设备上。\[3\] Anomaly Transformer的代码可以在GitHub上找到,具体地址是:GitHub - thuml/Anomaly-Transformer: About Code release for "Anomaly Transformer: Time Series Anomaly Detection with Association Discrepancy" (ICLR 2022 Spotlight) \[1\]。你可以在该代码库中找到更多关于Anomaly Transformer的实现细节和使用方法。 #### 引用[.reference_title] - *1* *3* [Anomaly-Transformer (ICLR 2022 )代码通过CPU复现](https://blog.csdn.net/weixin_44385635/article/details/130146282)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [TranAD: Deep Transformer Networks for Anomaly Detection in Multivariate Time Series Data](https://blog.csdn.net/zj_18706809267/article/details/125059124)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

卢颜娜

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值