I am trying to implement a kernelized probabilistic matrix factorization which is mentioned in this paper. KPMF Paper. I have coded two update functions as two separate methods. I don't know if this is a correct implementation or not. Can somebody help me understand if the implementation is correct? Below are the two functions:

\begin{equation} \frac{\partial E}{\partial U_{n,d}} = -\frac{1}{\sigma^2}\sum_{m=1}^{M}\delta_{n,m}(R_{n,m}-U_{n,:}V^T_{m,:})V_{d,m} + e^T_nS_UU_{:,d} \end{equation}

\begin{equation} \frac{\partial E}{\partial U_{n,d}} = -\frac{1}{\sigma^2}\sum_{n=1}^{N}\delta_{n,m}(R_{n,m}-U_{n,:}V^T_{m,:})U_{d,n} + e^T_mS_VV_{:,d} \end{equation}

 def run_U(self,U,V,R,en,su):
    Uhat = np.zeros(U.shape)
    for i in range(U.shape[0]):
        for z in range(U.shape[1]):
            fty = 0
            en[0,i] = 1
            gty = (en.dot(su)).dot(U[:,z])
            for k in range(len(V)):
                if R[i,k] != 0:
                    fty += (R[i,k] - (U[i,:].dot((V[k,:]).T)))*(V[k,z].T)
                    fty = 0
            Uhat[i,z] = gty+fty
    return Uhat

def run_V(self,U,V,R,em,sv):
    Vhat = np.zeros(V.shape)
    for i in range(V.shape[0]):
        for z in range(V.shape[1]):
            fty = 0
            em[0,i] = 1
            gty = (em.dot(sv)).dot(V[:,z])
            for k in range(len(U)):
                if R[k,i] != 0:
                    fty += (R[k,i] - (U[k,:].dot((V[i,:]).T)))*(U[k,z].T)
                    fty = 0
            Vhat[i,z] = gty + fty
    return Vhat 
  • $\begingroup$ Welcome to the site. It would help if you add a summary of the parameters in the equation (what they represent) in the question. $\endgroup$
    – hssay
    Aug 23, 2018 at 1:47
  • $\begingroup$ Thanks for your response. $\delta_{n,m}$ is an identifier and $R$,$U$,$V$ are matrices. $e_n$ and $e_m$ are unit vectors and $S_u$ and $S_v$ are matrices as well. Does that help or do you need the size of the matrices as well? The model works but I can't validate them because it's a new dataset that I have been working on. There's no baseline. I can tell that it works better than basic MF technique. $\endgroup$
    – Danny
    Aug 23, 2018 at 15:26


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.