amazon-web-services - AWS - Sage Maker 随机砍伐森林
问题描述
我有 aws cpu-utilization 数据,NAB 用于使用 AWS-SageMaker Random Cut Forest 创建异常检测。我能够执行它,但我需要更深入的超参数调整解决方案。我已经阅读了 AWS 文档,但需要了解 Hyper Parameter 选择。参数是有根据的猜测还是我们需要计算 co_disp 的均值和标准差以推断参数。
提前致谢。
我尝试了 100 Trees 和 512/256 tree_size 来检测异常,但是如何推断这些参数
# Set tree parameters
num_trees = 50
shingle_size = 48
tree_size = 512
# Create a forest of empty trees
forest = []
for _ in range(num_trees):
tree = rrcf.RCTree()
forest.append(tree)
# Use the "shingle" generator to create rolling window
#temp_data represents my aws_cpuutilization data
points = rrcf.shingle(temp_data, size=shingle_size)
# Create a dict to store anomaly score of each point
avg_codisp = {}
# For each shingle...
for index, point in enumerate(points):
# For each tree in the forest...
for tree in forest:
# If tree is above permitted size, drop the oldest point (FIFO)
if len(tree.leaves) > tree_size:
tree.forget_point(index - tree_size)
# Insert the new point into the tree
tree.insert_point(point, index=index)
"""Compute codisp on the new point and take the average among all
trees"""
if not index in avg_codisp:
avg_codisp[index] = 0
avg_codisp[index] += tree.codisp(index) / num_trees
values =[]
for key,value in avg_codisp.items():
values.append(value)
解决方案
感谢您对 RandomCutForest 的关注。如果您已标记异常,我们建议您使用 SageMaker 自动模型调整 ( https://docs.aws.amazon.com/sagemaker/latest/dg/automatic-model-tuning.html ),并让 SageMaker 找到最有效的组合.
试探性地,如果您知道您的数据有 0.4% 的异常,例如,您可以将每棵树的样本数设置为 N = 1 / (0.4 / 100) = 250。这背后的想法是每棵树代表一个样本你的数据。树中的每个数据点都被认为是“正常的”。如果您的树的点太少,例如 10,那么大多数点看起来与这些“正常”点不同,即它们的异常分数很高。
树的数量与基础数据之间的关系更为复杂。随着“正常”点范围的扩大,您会想要更多的树。
推荐阅读
- sqlite - 如何在房间 SQLite 数据库中自动设置时间戳?
- javascript - 通过_id匹配并提取两个对象数组之间的元素
- angular - Angular 8嵌套的ngFor - 点击事件影响所有其他项目
- elasticsearch - 在 Elasticsearch 中根据 document 生成 Document id
- react-native - 后退按钮反应本机 Web 视图
- javascript - 从另一个数组中的数组中删除对象
- php - 引导输入标签应用所需的验证
- vue.js - 为什么类星体开发不工作,当执行类星体开发?
- python - 为什么我们在 python 中使用多态性和抽象类
- python-3.x - Python Pandas:如何插入一个新列,该列是另一列的下一个“n”(也可以是分数)值的总和?