I have 3 one-hot-encoded columns where the header names are labels, and one prediction column preds
where the labels are predicted (see image). I want to calculate the performance of my predictions by comparing the label in preds
and the 1-encoded column header.
In this example I only have 20% predicted correctly.
Is there a quick way of doing this in pandas?
IIUC, DataFrame.lookup
and np.mean
df[['Type_1','Type_2','Type_3']].lookup(df.index, df['preds']).mean() * 100