holisticai.bias.metrics.exposure_entropy#

holisticai.bias.metrics.exposure_entropy(mat_pred, top=None, thresh=0.5, normalize=False)[source]#

Exposure Entropy

This function measures the entropy of the item exposure distribution.

Interpretation

A low entropy (close to 0) indicates high certainty as to which itemwill be shown. Higher entropies therefore ensure a morehomogeneous distribution. Scale is relative to number of items.

Parameters

mat_predmatrix-like

Matrix with shape (num_users, num_items). A recommenderscore (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

Exposure Entropy

Notes

\(-\sum_{k}{ p_k} \ln(p_k)\)

Examples

>>> import numpy as np
>>> from holisticai.bias.metrics import exposure_entropy
>>> 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]])
>>> exposure_entropy(mat_pred, top=None, thresh=0.3, normalize=True)
1.3762266043445464