Recommendation.jl

Build StatusCoverage Status

Recommendation.jl is a minimal, customizable Julia package for building recommender systems. Pre-built basic functionalities include:

  • Non-personalized baselines that give unsophisticated, rule-based recommendation.
  • Collaborative filtering on either explicit or implicit user-item matrix.
  • Content-based filtering by using the TF-IDF weighting technique.
  • Evaluation based on a variety of rating and ranking metrics, with easy-to-use N-fold cross validation executor.

Installation

julia> using Pkg; Pkg.add("Recommendation")

Usage

This package contains DataAccessor and several fundamental recommendation techniques (e.g., non-personalized MostPopular recommender, CF and MF), and evaluation metrics such as Recall:

All of them can be accessible by loading the package as follows:

using Recommendation

First of all, you need to create a data accessor from a matrix:

using SparseArrays

data = DataAccessor(sparse([1 0 0; 4 5 0]))

or set of events:

n_user, n_item = 5, 10

events = [Event(1, 2, 1), Event(3, 2, 1), Event(2, 6, 4)]

data = DataAccessor(events, n_user, n_item)

where Event() is a composite type which represents a user-item interaction:

type Event
    user::Int
    item::Int
    value::Float64
end

Next, you can pass the data accessor to an arbitrary recommender as:

recommender = MostPopular(data)

and building a recommendation engine should be easy:

build!(recommender)

Personalized recommenders sometimes require us to specify the hyperparameters:

help?> Recommendation.MF
  MF(
      data::DataAccessor,
      k::Int
  )
recommender = MF(data, 2)
build!(recommender, learning_rate=15e-4, max_iter=100)

Once a recommendation engine has been built successfully, top-2 recommendation for a user 4 is performed as follows:

# for user#4, pick top-2 from all items
recommend(recommender, 4, 2, collect(1:n_item))

See documentation for the details.