Multi-label Classification involves more than 1 label for every instance. This is mostly the case in recommendation systems where a user can have more than 1 preferences.

So can we use the same metrics here as well? Yes, but with a little tweak. Let’s have a look.

Precision @ K means calculating the number of correctly predicted labels out of the total labels. And the K means the top K labels to be considered.

Confusing? Here’s an example.

Consider that there can be 3 labels - 1,2,3 at max for each instance. Let’s say the prediction for first instance were classes [1,2,3] and the actual labels were [0,1,2].

Now, P@3 (K=3) would mean number of correctly predicted labels out of top 3 (here 3 is the max itself for ease of understanding) divided by 3.

So P@3 = 2/3, which will be 0.67, P@2 would be 0.5 and P@1 would be 0.

Now, what we can do is take P@1, P@2 and P@3 and take their average for a better measure. This is known as Average Precision @ K (AP@K).

So, AP@3 would be (P@1+P@2+P@3)/3, which will be (0+0.5+0.67)/3 = 0.38 in our case.

But this again is for just one instance. What we can do further is, take a mean of the values of AP@3 for each instance. This is known as Mean Average Precision @ K.👁️🗨️

#datascience #machinelearning