プリンキピア

第21章推薦システム

21.5.2. Hinge Loss and its Implementation21.5.2 ヒンジ損失とその実装

The Hinge loss for ranking has different form to the hinge loss provided within the gluon library that is often used in classifiers such as SVMs. The loss used for ranking in recommender systems has the following form.
英語のヒント
ランキングのためのヒンジ損失は、SVMのような分類器でよく使われる、gluonライブラリの中で用意されているヒンジ損失とは形が異なる。推薦システムでランキングに使われる損失は、次の形をしている。
∑(u,i,j∈D)max(m−yˆui+yˆuj,0)(21.5.3)
where m is the safety margin size. It aims to push negative items away from positive items. Similar to BPR, it aims to optimize for relevant distance between positive and negative samples instead of absolute outputs, making it well suited to recommender systems.
英語のヒント
ここでmは安全マージンの大きさである。これは、負例のアイテムを正例のアイテムから遠ざけることを目指す。BPRと同じように、絶対的な出力ではなく正例と負例の標本の間の距離を最適化することを目指すので、推薦システムによく適している。
#@save
class HingeLossbRec(gluon.loss.Loss):
    def __init__(self, weight=None, batch_axis=0, **kwargs):
        super(HingeLossbRec, self).__init__(weight=None, batch_axis=0,
                                            **kwargs)

    def forward(self, positive, negative, margin=1):
        distances = positive - negative
        loss = np.sum(np.maximum(- distances + margin, 0))
        return loss
These two losses are interchangeable for personalized ranking in recommendation.
英語のヒント
この二つの損失は、推薦における個人化ランキングで互いに置き換えられる。