我正在阅读Collaborative Filtering for Implicit Feedback Datasets。在第 6 页,他们详细介绍了他们的评估策略,他们使用以下公式将其定义为平均预期百分比排名:
这与 Datacamp 定义为隐式推荐引擎的适当错误度量的公式相同,只是他们称之为“排名排序错误度量”。我在 Spark 中实现系统,所以我定义了一个测试数据集来尝试一下:
test_df = spark.createDataFrame(
[
("A", "Fish", 1, 1),
("A", "Dogs", 2, 2),
("A", "Cats", 3, 3),
("A", "Elephants", 4, 4),
("B", "Fish", 1, 1),
("B", "Dogs", 2, 2),
("B", "Cats", 3, 3),
("B", "Elephants", 4, 4)
], ["Customer", "Item", "ImplicitRating", "PredictedRating"]
)
rankWindow = Window.partitionBy("Customer").orderBy(desc("PredictedRating"))
test_df\
.withColumn("RankUI", percent_rank().over(rankWindow))\
.withColumn("RankUIxRating", col("RankUI") * col("ImplicitRating"))\
.show()
输出是:
+--------+---------+--------------+---------------+------------------+------------------+
|Customer| Item|ImplicitRating|PredictedRating| RankUI| RankUIxRating|
+--------+---------+--------------+---------------+------------------+------------------+
| B|Elephants| 4| 4| 0.0| 0.0|
| B| Cats| 3| 3|0.3333333333333333| 1.0|
| B| Dogs| 2| 2|0.6666666666666666|1.3333333333333333|
| B| Fish| 1| 1| 1.0| 1.0|
| A|Elephants| 4| 4| 0.0| 0.0|
| A| Cats| 3| 3|0.3333333333333333| 1.0|
| A| Dogs| 2| 2|0.6666666666666666|1.3333333333333333|
| A| Fish| 1| 1| 1.0| 1.0|
+--------+---------+--------------+---------------+------------------+------------------+
通过设置预测的“评级”以匹配隐式评级,我在这里有效地建模了一个完美的预测。我的问题是,将这些值代入上面的公式会给我...
鉴于该论文明确表示的较低值更好,并且它们的值低至 ~ 8%,我很困惑如何将我在这个实验中的经验.
我究竟做错了什么?