第21章推薦システム
21.5.1. Bayesian Personalized Ranking Loss and its Implementation21.5.1 ベイズ個人化ランキング損失とその実装
Bayesian personalized ranking (BPR) (Rendle et al., 2009) is a pairwise personalized ranking loss that is derived from the maximum posterior estimator. It has been widely used in many existing recommendation models. The training data of BPR consists of both positive and negative pairs (missing values). It assumes that the user prefers the positive item over all other non-observed items.
英語のヒント
ベイズ個人化ランキング(BPR)(Rendle et al., 2009)は、最大事後確率推定量から導かれるペアワイズの個人化ランキング損失である。これは、既存の多くの推薦モデルで広く使われてきた。BPRの訓練データは、正例と負例(欠損値)の両方の組からなる。BPRは、利用者が、正例のアイテムをほかのすべての観測されていないアイテムよりも好むと仮定する。
In formal, the training data is constructed by tuples in the form of , which represents that the user prefers the item over the item . The Bayesian formulation of BPR which aims to maximize the posterior probability is given below:
英語のヒント
形式的には、訓練データはの形のタプルで構成され、これは利用者がアイテムよりもアイテムを好むことを表す。事後確率を最大化することを目指すBPRのベイズ的な定式化は、次のとおりである。
(21.5.1)
Where represents the parameters of an arbitrary recommendation model, represents the desired personalized total ranking of all items for user . We can formulate the maximum posterior estimator to derive the generic optimization criterion for the personalized ranking task.
英語のヒント
ここでは任意の推薦モデルのパラメータを表し、は利用者にとってのすべてのアイテムの望ましい個人化された全順序を表す。最大事後確率推定量を定式化して、個人化ランキングのタスクのための汎用の最適化基準を導ける。
(21.5.2)
where is the training set, with denoting the items the user liked, denoting all items, and indicating all other items excluding items the user liked. and are the predicted scores of the user to item and , respectively. The prior is a normal distribution with zero mean and variance-covariance matrix . Here, we let .
英語のヒント
ここでは訓練集合であり、は利用者が好んだアイテム、はすべてのアイテム、は利用者が好んだアイテムを除いたほかのすべてのアイテムを表す。とは、それぞれアイテムとに対する利用者の予測点数である。事前分布は、平均0で分散共分散行列がの正規分布である。ここではとする。
We will implement the base class
mxnet.gluon.loss.Loss and override the forward method to construct the Bayesian personalized ranking loss. We begin by importing the Loss class and the np module.英語のヒント
基底クラス
mxnet.gluon.loss.Lossを実装し、forwardメソッドをオーバーライドして、ベイズ個人化ランキング損失を作る。まず、Lossクラスとnpモジュールをインポートする。from mxnet import gluon, np, npx
npx.set_np()The implementation of BPR loss is as follows.
英語のヒント
BPR損失の実装は次のとおりである。
#@save
class BPRLoss(gluon.loss.Loss):
def __init__(self, weight=None, batch_axis=0, **kwargs):
super(BPRLoss, self).__init__(weight=None, batch_axis=0, **kwargs)
def forward(self, positive, negative):
distances = positive - negative
loss = - np.sum(np.log(npx.sigmoid(distances)), 0, keepdims=True)
return loss