gpt4 book ai didi

python - pycaret 和 H2O 之间异常检测的不同结果

转载 作者:行者123 更新时间:2023-12-04 12:09:03 49 4
gpt4 key购买 nike

我正在从以下数据中检测异常:
enter image description here
它来自液压系统的处理信号,从那里我知道红框中的点是系统故障时发生的异常。
我正在使用前 3k 条记录来训练模型,包括 pycaret 和 H20。这 3k 条记录涵盖了 5 个数据周期,如下图所示:
要在 pycaret 中训练模型,我使用以下代码:
enter image description here

from pycaret.anomaly import *
from pycaret.datasets import get_data
import pandas as pd
exp_ano101 = setup(df[["Pressure_median_mw_2500_ac"]][0:3000], normalize = True,
session_id = 123)

iforest = create_model('iforest')
unseen_predictions = predict_model(iforest, data=df[["Pressure_median_mw_2500_ac"]])
unseen_predictions = unseen_predictions.reset_index()
我从 pycaret 得到的结果非常好:
enter image description here
通过一些后期处理,我可以获得以下效果,这非常接近理想状态:
enter image description here
另一方面,使用 H20,代码如下:
import pandas as pd
from h2o.estimators import H2OIsolationForestEstimator, H2OGenericEstimator
import tempfile
ifr = H2OIsolationForestEstimator()
ifr.train(x="Pressure_median_mw_2500_ac",training_frame=hf)
th = df["mean_length"][0:3000].quantile(0.05)
df["anomaly"] = df["mean_length"].apply(lambda x: "1" if x> th else "0")
我明白了:
enter image description here
这是一个巨大的差异,因为它没有将此块检测为异常:
enter image description here
我的疑问是,鉴于我使用的是相同的算法,即隔离森林,我怎样才能获得与从 pycaret 获得的结果相似的结果。甚至在 Pycaret 中使用 SVM 也比在 H2O 中使用隔离森林得到更接近的结果
enter image description here

最佳答案

Pycaret 使用库 PyOD 进行异常检测。然后是 PyOD 与 H2O。也许有不同的默认参数。在 Pycaret (PyOD) 中可以修改参数分数 - 默认值 = 0.05,数据集中异常值的百分比/比例。
您应该尝试使用此参数,也许您会从两个库中获得相同的结果。

关于python - pycaret 和 H2O 之间异常检测的不同结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68461155/

49 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com