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
matrix_factorization.py 文件源码
python
阅读 33
收藏 0
点赞 0
评论 0
评论列表
文章目录