#!/usr/bin/env python
"""Probabilistic matrix factorization using variational inference.
Visualizes the actual and the estimated rating matrices as heatmaps.
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import edward as ed
import matplotlib.pyplot as plt
import numpy as np
import tensorflow as tf
from edward.models import Normal
def build_toy_dataset(U, V, N, M, noise_std=0.1):
R = np.dot(np.transpose(U), V) + np.random.normal(0, noise_std, size=(N, M))
return R
This file has been truncated. show original
The example use variational inference
How do I use gibbs sampling to do the same thing?
dustin
May 29, 2017, 12:30am
2
I highly recommend https://github.com/dadaromeo/recsys-hpf . It uses Edward to do Monte Carlo EM (Gibbs sampling + MAP) for hierarchical Poisson factorization. (this is one of the SOTA recommender system models)