lenskit.metrics.ExposureGini#
- class lenskit.metrics.ExposureGini(n=None, *, k=None, items, weight=<lenskit.metrics.ranking._weighting.GeometricRankWeight object>)#
Bases:
GiniBaseMeasure exposure distribution of recommendations with the Gini coefficient.
This uses a weighting model to compute the exposure of each item in each list, and computes the Gini coefficient of the total exposure.
- Parameters:
n (int | None) – The maximum recommendation list length.
items (int | pd.Series | pd.DataFrame | Dataset) – The total number of items, a data frame or series of item data, or a dataset. If a frame or series is provided, its length will be used as the number of items. If a dataset is provided, its item count will be used.
weight (RankWeight) – The rank weighting model to use. Defaults to
GeometricRankWeightwith the specified patience parameter.k (int | None)
- Stability:
- Caller (see Stability Levels).
- __init__(n=None, *, k=None, items, weight=<lenskit.metrics.ranking._weighting.GeometricRankWeight object>)#
Methods
__init__([n, k, weight])compute_list_data(output, test)Compute measurements for a single list.
extract_list_metric(data, /)Extract a single-list metric from the per-list measurement result (if applicable).
extract_list_metrics(data, /)Extract per-list metric(s) from intermediate measurement data.
global_aggregate(values)Aggregate list metrics to compute a global value.
measure_list(output, test, /)Compute measurements for a single list.
summarize(values, /)Aggregate intermediate values into summary statistics.
truncate(items)Truncate an item list if it is longer than
n.Attributes
klabelDefault name — class name, optionally @N.
nThe maximum length of rankings to consider.
set_kweightitem_count- compute_list_data(output, test)#
Compute measurements for a single list.
Use measure_list in Metric for new implementations.
- Parameters:
output (ItemList)
- global_aggregate(values)#
Aggregate list metrics to compute a global value.
Implement
Metric.summarize()in new implementations.- Parameters:
values (list[tuple[Array, FloatArray]])