holisticai.bias.metrics.avg_recommendation_popularity#
- holisticai.bias.metrics.avg_recommendation_popularity(mat_pred, top=None, thresh=0.5, normalize=False)[source]#
Average Recommendation Popularity
This function computes the average recommendation popularity of items over users. We define the recommendation popularity as the average amount of times an item is recommended.
Interpretation
A low value is desidered and suggests that items have been recommended equally across the population.
Parameters
- mat_predmatrix-like
Matrix with shape (num_users, num_items). A recommender score (binary or soft pred) for each user,item interaction.
- topint, optional
If not None, the number of items that are shown to each user.
- threshfloat, optional
Threshold indicating value at which a given item is shown to user (if top is None).
- normalizebool, optional
If True, normalises the data matrix to [0,1] range.
Returns
- float
Average Recommendation Popularity
References
Examples
>>> import numpy as np >>> from holisticai.bias.metrics import avg_recommendation_popularity >>> mat_pred = np.array([[0.9, 0.8, 0.4, 0.2], [0.7, 0.9, 0.1, 0.7], [0.3, 0.2, 0.3, 0.3], [0.2, 0.1, 0.7, 0.8], [0.8, 0.7, 0.9, 0.1], [1. , 0.9, 0.3, 0.6], [0.8, 0.9, 0.1, 0.1], [0.2, 0.3, 0.1, 0.5], [0.1, 0.2, 0.7, 0.7], [0.2, 0.7, 0.1, 0.2]]) >>> avg_recommendation_popularity(mat_pred, top=None, thresh=0.5, normalize=False) 5.037037037037036