Python 中的 ADTK 异常值检测/过滤

发布于 2025-01-14 03:34:07 字数 610 浏览 4 评论 0原文

我正在尝试解决我所拥有的数据集中的异常情况。这是进程的 CPU 使用率数据。

我的数据如下所示 输入图片此处描述

我查找异常的代码如下所示

outlier_detector = OutlierDetector(LocalOutlierFactor(contamination=0.05))
anomalies = outlier_detector.fit_detect(df_anomaly)
print(anomalies)

异常输出显示如下所示

在此处输入图像描述

如何过滤具有 的所有值的异常输出集合中正确?异常输出是数据帧还是其他东西?

I am trying to fine anomalies in the data set I have. This is CPU usage data for a process.

My data looks something like below
enter image description here

My code to find anomalies looks like something below

outlier_detector = OutlierDetector(LocalOutlierFactor(contamination=0.05))
anomalies = outlier_detector.fit_detect(df_anomaly)
print(anomalies)

The anomalies output shows me something like below

enter image description here

How can I filter the anomalies output for all values which have True in the set? Is anomalies output a dataframe or something else?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

绝不放开 2025-01-21 03:34:07

GitHub 上的贡献者回答了这个问题。

anomalies 对象是一个 pandas.core.series.Series
您可以将其转换为列表并在您自己的图中使用数据。

# With datetime and boolean
anomailes_list = anomalies.reset_index().values.tolist()
anomailes_list
# Just boolean results
anomailes_list = anomalies.to_list()
anomailes_list

# List of values that are True
anomalies_true = [value for value in anomalies.to_list() if value]

The question was answered by Contributors on GitHub.

The anomalies object is a pandas.core.series.Series
You can convert it to a list and use the data in your own plot.

# With datetime and boolean
anomailes_list = anomalies.reset_index().values.tolist()
anomailes_list
# Just boolean results
anomailes_list = anomalies.to_list()
anomailes_list

# List of values that are True
anomalies_true = [value for value in anomalies.to_list() if value]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文