matrix_factorization.py 文件源码

python
阅读 33 收藏 0 点赞 0 评论 0

项目:probabilistic-matrix-factorization 作者: aki-nishimura 项目源码 文件源码
def update_weight_param(self, mu0, r, u, c, v):
        # Returns the weight parameters in an 1-D array in the row major order
        # and also the mean estimate of matrix factorization as a by-product.

        mu = self.compute_model_mean(self.y_coo.row, self.y_coo.col, mu0, r, u, c, v)

        if math.isinf(self.prior_param['obs_df']):
            phi = self.prior_param['weight']
        else:
            prior_shape = self.prior_param['obs_df'] / 2
            prior_rate = self.prior_param['obs_df'] / 2 / self.prior_param['weight']
            sq_error = (self.y_coo.data - mu) ** 2
            post_shape = prior_shape + 1 / 2
            post_rate = prior_rate + sq_error / 2
            phi = np.random.gamma(post_shape, 1 / post_rate)

        return phi, mu
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号