[Python] How to properly remove outliers in sensor data?

Discussão em 'Python' iniciado por Stack, Julho 12, 2025.

  1. Stack

    Stack Membro Participativo

    I previously used the code below, but it ended up resulting in my graphs jumbling into chaos(data values far exceeding what is humanly possible to exert with their feet). I'm kind of curious because I see most people using z-score for removing outliers, but the implementation didn't work for me. Is my implementation wrong or is there a better way to approach this?

    mean = np.mean(curr_data, axis=0)
    std = np.std(curr_data, axis=0)

    mask = np.abs(curr_data - mean) <= (3 * std)
    curr_data[~mask] = -1

    means = np.array([
    np.mean(row[row >= 0]) if np.any(row >= 0) else 0
    for row in curr_data
    ])
    curr_data = np.where(mask,curr_data,means[:, None])


    Example of Data: [​IMG]

    Continue reading...

Compartilhe esta Página