Multilabel Ranking Metrics-Label Ranking Average Precision | ML
0
1
Code : Python code to implement LRAP
# import numpy and scikit-learn libraries import numpy as np from sklearn.metrics import label_ranking_average_precision_score # take sample datasets y_true = np.array([[ 1 , 0 , 0 ], [ 1 , 0 , 1 ], [ 1 , 1 , 0 ]]) y_score = np.array([[ 0.75 , 0.5 , 1 ], [ 1 , 0.2 , 0.1 ], [ 0.9 , 0.7 , 0.6 ]]) # print the output print (label_ranking_average_precision_score( y_true, y_score)) |
Output :
0.777
[1, 0, 0]
[0, 1, 0]
[0, 0, 1]
[1, 0, 0], [1, 0, 1], [1, 1, 0]
5
nd