首页 > 解决方案 > 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)

标签: amazon-web-servicesmachine-learningartificial-intelligencedata-scienceamazon-sagemaker

解决方案


感谢您对 RandomCutForest 的关注。如果您已标记异常,我们建议您使用 SageMaker 自动模型调整 ( https://docs.aws.amazon.com/sagemaker/latest/dg/automatic-model-tuning.html ),并让 SageMaker 找到最有效的组合.

试探性地,如果您知道您的数据有 0.4% 的异常,例如,您可以将每棵树的样本数设置为 N = 1 / (0.4 / 100) = 250。这背后的想法是每棵树代表一个样本你的数据。树中的每个数据点都被认为是“正常的”。如果您的树的点太少,例如 10,那么大多数点看起来与这些“正常”点不同,即它们的异常分数很高。

树的数量与基础数据之间的关系更为复杂。随着“正常”点范围的扩大,您会想要更多的树。


推荐阅读