プリンキピア

第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 (u,i,j), which represents that the user u prefers the item i over the item j. The Bayesian formulation of BPR which aims to maximize the posterior probability is given below:
英語のヒント
形式的には、訓練データは(u,i,j)の形のタプルで構成され、これは利用者uがアイテムjよりもアイテムiを好むことを表す。事後確率を最大化することを目指すBPRのベイズ的な定式化は、次のとおりである。
p(Θ∣>u)∝p(>u∣Θ)p(Θ)(21.5.1)
Where Θ represents the parameters of an arbitrary recommendation model, >u represents the desired personalized total ranking of all items for user u. We can formulate the maximum posterior estimator to derive the generic optimization criterion for the personalized ranking task.
英語のヒント
ここでΘは任意の推薦モデルのパラメータを表し、>uは利用者uにとってのすべてのアイテムの望ましい個人化された全順序を表す。最大事後確率推定量を定式化して、個人化ランキングのタスクのための汎用の最適化基準を導ける。
BPR-OPT:=ln⁡p(Θ∣>u)∝ln⁡p(>u∣Θ)p(Θ)=ln⁡∏(u,i,j∈D)σ(yˆui−yˆuj)p(Θ)=∑(u,i,j∈D)ln⁡σ(yˆui−yˆuj)+ln⁡p(Θ)=∑(u,i,j∈D)ln⁡σ(yˆui−yˆuj)−λΘ∥Θ∥2(21.5.2)
where D=def{(u,i,j)∣i∈Iu+∧j∈I∖Iu+} is the training set, with Iu+ denoting the items the user u liked, I denoting all items, and I∖Iu+ indicating all other items excluding items the user liked. yˆui and yˆuj are the predicted scores of the user u to item i and j, respectively. The prior p(Θ) is a normal distribution with zero mean and variance-covariance matrix ΣΘ. Here, we let ΣΘ=λΘI.
英語のヒント
ここでD=def{(u,i,j)∣i∈Iu+∧j∈I∖Iu+}は訓練集合であり、Iu+は利用者uが好んだアイテム、Iはすべてのアイテム、I∖Iu+は利用者が好んだアイテムを除いたほかのすべてのアイテムを表す。yˆuiとyˆujは、それぞれアイテムiとjに対する利用者uの予測点数である。事前分布p(Θ)は、平均0で分散共分散行列がΣΘの正規分布である。ここではΣΘ=λΘIとする。
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