如何处理时间序列数据集中的异常值?

数据挖掘 Python 数据集 回归
2022-03-10 18:22:39

我已阅读以下有关如何处理数据集中异常值的文章:http: //napitupulu-jon.appspot.com/posts/outliers-ud120.html

基本上,他删除了所有与大多数有巨大差异的 y:

def outlierCleaner(predictions, ages, net_worths):
    """
        clean away the 10% of points that have the largest
        residual errors (different between the prediction
        and the actual net worth)

        return a list of tuples named cleaned_data where 
        each tuple is of the form (age, net_worth, error)
    """

    #calculate the error,make it descend sort, and fetch 90% of the data

    errors = (net_worths-predictions)**2
    cleaned_data =zip(ages,net_worths,errors)
    cleaned_data = sorted(cleaned_data,key=lambda x:x[2][0], reverse=True)
    limit = int(len(net_worths)*0.1)


    return cleaned_data[limit:]

但是,如果它的行是相关的,我如何将这种技术应用于时间序列数据集?

1个回答
  1. 确定时间序列中您的常见事件的自相关程度。例如,“我正在跟踪一段时间内的温度,它在一小时内的变化很少超过 30 华氏度”。

  2. 丢弃或平滑观察值变化大于该值的任何 换句话说,“如果我看到温度在一小时内变化超过 30 度,我将忽略该值并替换上一个值和下一个值的平均值,因为这一定是传感器故障”。

一旦您对此感到满意,请使用滚动窗口上数据的标准偏差之类的东西,而不是像我那样使用绝对的、任意的值。