第21章推薦システム
21.3.1. The Matrix Factorization Model21.3.1 行列分解のモデル
Matrix factorization is a class of collaborative filtering models. Specifically, the model factorizes the user-item interaction matrix (e.g., rating matrix) into the product of two lower-rank matrices, capturing the low-rank structure of the user-item interactions.
英語のヒント
行列分解は、協調フィルタリングのモデルの一種である。具体的には、このモデルは、利用者とアイテムのやりとり行列(たとえば評価行列)を二つのより低いランクの行列の積に分解し、利用者とアイテムのやりとりの低ランクの構造をとらえる。
Let denote the interaction matrix with users and items, and the values of represent explicit ratings. The user-item interaction will be factorized into a user latent matrix and an item latent matrix , where , is the latent factor size. Let denote the row of and denote the row of . For a given item , the elements of measure the extent to which the item possesses those characteristics such as the genres and languages of a movie. For a given user , the elements of measure the extent of interest the user has in items’ corresponding characteristics. These latent factors might measure obvious dimensions as mentioned in those examples or are completely uninterpretable. The predicted ratings can be estimated by
英語のヒント
を、人の利用者と個のアイテムからなるやりとり行列とし、の値は明示的な評価を表すとする。利用者とアイテムのやりとりは、利用者の潜在行列とアイテムの潜在行列に分解される。ここでは潜在因子の大きさである。をのの行、をのの行とする。与えられたアイテムについて、の要素は、映画のジャンルや言語のような特性をそのアイテムがどの程度もっているかを測る。与えられた利用者について、の要素は、アイテムの対応する特性にその利用者がどの程度関心をもっているかを測る。これらの潜在因子は、これらの例で述べたような明らかな次元を測っていることもあれば、まったく解釈できないこともある。予測される評価は次の式で推定できる。
(21.3.1)
where is the predicted rating matrix which has the same shape as . One major problem of this prediction rule is that users/items biases can not be modeled. For example, some users tend to give higher ratings or some items always get lower ratings due to poorer quality. These biases are commonplace in real-world applications. To capture these biases, user specific and item specific bias terms are introduced. Specifically, the predicted rating user gives to item is calculated by
英語のヒント
ここでは、と同じ形をした予測評価行列である。この予測規則の大きな問題の一つは、利用者やアイテムのバイアスをモデル化できないことである。たとえば、高めの評価をつけがちな利用者もいれば、質が劣るためにいつも低めの評価を受けるアイテムもある。こうしたバイアスは、現実の応用ではありふれている。これらのバイアスをとらえるため、利用者に固有のバイアス項とアイテムに固有のバイアス項を導入する。具体的には、利用者がアイテムにつける予測評価は、次の式で計算される。
(21.3.2)
Then, we train the matrix factorization model by minimizing the mean squared error between predicted rating scores and real rating scores. The objective function is defined as follows:
英語のヒント
それから、予測された評価の点数と実際の評価の点数の間の平均二乗誤差を最小化することで、行列分解のモデルを訓練する。目的関数は次のように定義される。
(21.3.3)
where denotes the regularization rate. The regularizing term is used to avoid over-fitting by penalizing the magnitude of the parameters. The pairs for which is known are stored in the set . The model parameters can be learned with an optimization algorithm, such as Stochastic Gradient Descent and Adam.
英語のヒント
ここでは正則化率を表す。正則化項は、パラメータの大きさに罰則を科すことで過学習を避けるために使われる。がわかっているの組は、集合に保存される。モデルのパラメータは、確率的勾配降下法やAdamのような最適化アルゴリズムで学習できる。
An intuitive illustration of the matrix factorization model is shown below:
英語のヒント
行列分解のモデルを直観的に図解すると、次のようになる。
Fig. 21.3.1図21.3.1
Illustration of matrix factorization model
英語のヒント
行列分解のモデルの図解
In the rest of this section, we will explain the implementation of matrix factorization and train the model on the MovieLens dataset.
英語のヒント
この節の残りでは、行列分解の実装を説明し、MovieLensのデータセットでモデルを訓練する。
import mxnet as mx
from mxnet import autograd, gluon, np, npx
from mxnet.gluon import nn
from d2l import mxnet as d2l
npx.set_np()