Add IPS-weighted RBP (#1155) - #1182
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1182 +/- ##
==========================================
+ Coverage 89.58% 89.63% +0.05%
==========================================
Files 262 264 +2
Lines 17405 17547 +142
==========================================
+ Hits 15593 15729 +136
- Misses 1812 1818 +6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Will provide a more detailed review tomorrow or Monday, but I just cut the 2026.3 release, so this will be targeted for 2026.4.0. |
mdekstrand
left a comment
There was a problem hiding this comment.
Thanks! Design looks good to me.
The thing I currently find unclear is gamma, and how to choose it, especially when we don't know the logging policy. Do we always need to use estimate_power_law_gamma, or is there a reasonable way to pick some default value? If we always need to use estimate_power_law_gamma, how should we generate the recommendations to do so?
| measured: the unbiasedness argument holds them fixed with respect to the | ||
| observations they weight. | ||
|
|
||
| .. versionadded:: 2026.3 |
| - Added :class:`lenskit.metrics.IPSRBP`, an IPS-weighted rank-biased precision | ||
| for missing-not-at-random implicit feedback, along with the propensity models | ||
| it uses (:issue:`1155`). |
There was a problem hiding this comment.
Move to new section for 2026.4.
|
|
||
| counts = _item_counts(data, count) | ||
| counts = counts[counts > 0] | ||
| shown = [items[:n].ids() for _, items in recs if len(items)] |
There was a problem hiding this comment.
this can be for items in recs.lists().
Adds IPS-weighted RBP (#1155), following Yang et al., "Unbiased Offline Recommender Evaluation for Missing-Not-At-Random Implicit Feedback" (RecSys 2018).
The metric is
IPSRBP. It uses the paper's self-normalized estimator (SNIPS, their eqn. 9) by default;self_normalized=Falsedrops the denominator and gives the plain IPS numerator. Propensities come from aPropensityModelpassed to the constructor:PopularityPropensityimplements their eqn. 15,UniformPropensityis the missing-at-random baseline, andFieldPropensityreads them off a field if you estimated them yourself. There's alsoestimate_power_law_gamma, which fits the exponent from a set of recommendations the way they do in section 4.3.I put the propensities in a separate object rather than as arguments on the metric, partly to follow
MeanPopRankandListGinitaking aDataset, and partly because it mirrorsRankWeight. IPS-corrected Recall or DCG should then just be a matter of reusing it.A few choices:
gammais the paper's exponent, so the(gamma+1)/2of eqn. 15 happens inside the propensity model and values from their Table 2 can be used as-is. It has no default, since it depends on the dataset and on whatever produced the log.Tests
Two identities tie the metric to the existing one, both checked with Hypothesis over random lists, cutoffs and patience values:
self_normalized=Falseis exactlyRBPRBP / |S*_u|I also checked both per user on ml-latest-small and they hold to machine precision.
There's also a small simulated MNAR log where the true reward of eqn. 1 is known: the uncorrected evaluator overstates a popularity-chasing recommender and the correction pulls it back, while on a missing-at-random log the correction leaves the score alone.
One thing I didn't do
The docstrings cite
yangUnbiasedOfflineRecommender2018, which isn't indocs/lenskit.bibyet.@inproceedings{yang2018unbiased,
title={Unbiased offline recommender evaluation for missing-not-at-random implicit feedback},
author={Yang, Longqi and Cui, Yin and Xuan, Yuan and Wang, Chenyang and Belongie, Serge and Estrin, Deborah},
booktitle={Proceedings of the 12th ACM conference on recommender systems},
pages={279--287},
year={2018}
}