def is_anomaly()

in flask/utils.py [0:0]


def is_anomaly(metric_data):
    """
    Checks if data point is anomalous... (e.g. populate a column with metric[key]['anomaly'] = is_anomaly(metrics))
    :param metric_data: A DataFrame of statistics for a specific metric, where 'diff_m' is the the difference in the
    observation and the moving average at time t, and 'mstd' is the moving standard deviation at time t
    :return: True if data point is anomalous, False if not
    """
    metric_data['z'] = metric_data['diff_m'] / metric_data['mstd']
    metric_data['anomaly'] = False
    for row in metric_data.index:
        if metric_data.ix[row, 'z'] >= 2 or metric_data.ix[row, 'z'] <= -2:
            metric_data.ix[row, 'anomaly'] = True
    return metric_data