Ranking Loss is defined as the number of incorrectly ordered labels with respect to the number of correctly ordered labels. The best value of ranking loss can be zero
Given a binary indicator matrix of ground-truth labels
The score associated with each label is denoted by where,
Ranking Loss can be calculated as :
where represents number of non-zero elements in the set and represents the number of elements in the vector (cardinality of the set). The minimum ranking loss can be 0. It is when all the labels are correctly ordered in prediction labels.
Code: Python code to implement Ranking Loss using the scikit-learn library.
In the first sample of the first prediction, the only non-zero label has ranked in top-2 values. similarly for the second and third samples. All have only one non-label in the ground truth label.
By putting these values in the formula we get,
In the second print statement, All the ground truth label corresponds to the highest value in the predicted label. Hence, the ranking loss is 0. We can also got the same answer when we put those values in the formula because the rightmost term for each sample is 0.
- Tsoumakas, G., Katakis, I., & Vlahavas, I. (2010). Mining multi-label data. In Data mining and knowledge discovery handbook (pp. 667-685). Springer US.
- Multilabel Ranking Metrics-Label Ranking Average Precision | ML
- ML | MultiLabel Ranking Metrics - Coverage Error
- Normalized Discounted Cumulative Gain - Multilabel Ranking Metrics | ML
- tf-idf Model for Page Ranking
- Ranking Rows of Pandas DataFrame
- PyQt5 QSpinBox - How to get the font metrics
- Python | Similarity metrics of strings
- PyQt5 QCalendarWidget - Accessing Font Metrics
- ML | Common Loss Functions
- ML | Log Loss and Mean Squared Error
- Top 10 Machine Learning Frameworks in 2020
- Python str() function
- Python vs Java - Who Will Win the Battle in 2020?
- Top 10 Data Science Skills to Learn in 2020
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.