时间序列异常检测(pycaret)

本文介绍了如何使用PyCaret进行时间序列异常检测。首先安装pycaret库,然后通过pycaret.anomaly模块检测异常。文章展示了如何获取并查看支持的所有异常检测模型,并对多个算法进行了测试。通过evaluate_model()和plot_model()函数评估和可视化模型,以便识别异常值。最后,文章提到了模型保存的过程,以iforest模型为例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1. 获取时间序列数据(官方文档是多特征,本文举例是单特征) 

未安装pycaret的先安装:pip install --pre pycaret (也可以pip install pycaret)

 

 2.用pycaret检测异常一般用pycaret.anomaly 

  

pycaret.anomaly的所有功能:
assign_model,
create_model,
deploy_model,
evaluate_model,
get_config,
get_logs,
load_config,
load_model,
models,
plot_model,
predict_model,
pull,
save_config,
save_model,
set_config,
set_current_experiment,
setup,
tune_model,
from pycaret.anomaly import *
setup = setup(df, session_id = 123)

 

 3.获取pycaret支持的所有检测异常模型

models()

def create_model(
    model: Union[str, Any],
    fraction: float = 0.05,
    verbose: bool = True,
    fit_kwargs: Optional[dict] = None,
    experiment_custom_tags: Optional[Dict[str, Any]] = None,
    **kwargs,
):
"""
This function trains a given model from the model library. All available
models can be accessed using the ``models`` function.
model: str or scikit-learn compatible object
    ID of an model available in the model library or pass an untrained
    model object consistent with scikit-learn API. Estimators available
    in the model library (ID - Name):

    * 'abod' - Angle-base Outlier Detection
    * 'cluster' - Clustering-Based Local Outlier
    * 'cof' - Connectivity-Based Outlier Factor
    * 'histogram' - Histogram-based Outlier Detection
    * 'knn' - k-Nearest Neighbors Detector
    * 'lof' - Local Outlier 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值