Giter Site home page Giter Site logo

rottenfruits / bpmf.jl Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 0.0 13 KB

A Julia package for bayesian probabilistic matrix factorization (BPMF).

License: MIT License

Julia 100.00%
julia bpmf variational-inference-algorithm gibbs-sampling-algorithm bayesian-inference bayesian bayes

bpmf.jl's Introduction

BPMF.jl

A Julia package for Bayesian Probabilistic Matrix Factorization (BPMF).


How to install

You can install BPMF.jl running the following commands.

  1. Into The Pkg REPL-mode
  • Enter the key] on the Julia REPL.
  1. Install the package
  • Enter the following commond.
(v1.0) pkg> add https://github.com/RottenFruits/BPMF.jl

Overview

This package is implementation bayesian probabilistic matrix factorization (BPMF).

Supported features:

  • Gibbs sampling algorithm
  • Variational Inference Algorithm

Example

Here are examples.

At first read package and generate data.

using BPMF

#data
R = [
    0 0 7;
    0 1 6;
    0 2 7;
    0 3 4;
    0 4 5;
    0 5 4;
    1 0 6;
    1 1 7;
    1 3 4;
    1 4 3;
    1 5 4;
    2 1 3;
    2 2 3;
    2 3 1;
    2 4 1;
    3 0 1;
    3 1 2;
    3 2 2;
    3 3 3;
    3 4 3;
    3 5 4;
    4 0 1;
    4 2 1;
    4 3 2;
    4 4 3;
    4 5 3;
]

Using Gibbs Sampling Algorithm

Following example is gibbs sampling algorithm.

N = length(unique(R[:, 1])) #number of unique users
M = length(unique(R[:, 2])) #number of unique items
D = 3 #number of latent dimensions
T = 100 #number of iterations
U = [] #user's latent factor
V = [] #item's latent factor
α = 2 #hyper parameter
β₀ = 2 #hyper parameter
μ₀ = 0 #hyper parameter
ν₀ = D #hyper parameter
W₀ = one(zeros(D, D)) #hyper parameter

#learning
gibbs_model = BPMF.GBPMFModel(R, N, M, D, T, U, V, α, β₀, μ₀, ν₀, W₀)
BPMF.fit(gibbs_model)

#predict new data
bi = 10 #burn-in
BPMF.predict(gibbs_model, R, bi)

Using Variational Inference Algorithm

Following example is variational inference algorithm.

N = length(unique(R[:, 1])) #number of unique users
M = length(unique(R[:, 2])) #number of unique items
D = 3 #number of latent dimensions
L = 10 #number of iterations
U = [] #user's latent factor
V = [] #item's latent factor
τ² = 1 #hyper parameter
σ² = [] #hyper parameter
ρ² = [] #hyper parameter

#learning
variational_model = BPMF.VBPMFModel(R, N, M, D, L, U, V, τ², σ², ρ²)
BPMF.fit(variational_model)

#predict new data
BPMF.predict(variational_model, R)

References

  • Salakhutdinov, Ruslan, and Andriy Mnih. "Bayesian probabilistic matrix factorization using Markov chain Monte Carlo." Proceedings of the 25th international conference on Machine learning. ACM, 2008.

  • Lim, Yew Jin, and Yee Whye Teh. "Variational Bayesian approach to movie rating prediction." Proceedings of KDD cup and workshop. Vol. 7. 2007.

  • LIVESENSE Data Analytics Blog, BPMF(Bayesian Probabilistic Matrix Factorization)によるレコメンド, https://analytics.livesense.co.jp/entry/2017/12/05/105618

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.