pythonpandasconfusion-matrixfalse-positive

Calculate a set of performance metrics from signals in a pandas column


I have a dataframe containing three of my signals as follows:

enter image description here

To evaluate the performance of the anomaly detector - I want to find out FP, FN, etc.

Using this setup - what is the best way of going about calculating FP, FN, and other relevant performance metrics (F1, Precision, Recall, etc.)? Is it possible to build a confusion matrix straight from this?


Solution

  • Try to use isna() test for that.

    df.loc[(~df['rr_filtered'].isna()) & (df['rr_manually_cleaned'].isna()), 'TEST'] = 'FN'
    
    df.loc[(~df['rr_manually_cleaned'].isna()) & (df['rr_filtered'].isna()), 'TEST'] = 'FP'