• Stars
    star
    169
  • Rank 224,453 (Top 5 %)
  • Language
    Go
  • License
    MIT License
  • Created over 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Recommender systems for Go

sbr-go

Build Status Godoc

A recommender system package for Go.

Sbr implements state-of-the-art sequence-based models, using the history of what a user has liked to suggest new items. As a result, it makes accurate predictions that can be updated in real-time in response to user actions without model re-training.

Sbr implements cutting-edge sequence-based recommenders: for every user, we examine what they have interacted up to now to predict what they are going to consume next.

Implemented models:

  • LSTM: a model that uses an LSTM network over the sequence of a user's interaction to predict their next action;
  • EWMA: a model that uses a simpler exponentially-weighted average of past actions to predict future interactions.

Which model performs the best will depend on your dataset. The EWMA model is much quicker to fit, and will probably be a good starting point.

Usage

You can fit a model on the Movielens 100K dataset in about 10 seconds using the following code:

	// Load the data.
	data, err := sbr.GetMovielens()
	if err != nil {
		panic(err)
	}
	fmt.Printf("Loaded movielens data: %v users and %v items for a total of %v interactions\n",
		data.NumUsers(), data.NumItems(), data.Len())

	// Split into test and train.
	rng := rand.New(rand.NewSource(42))
	train, test := sbr.TrainTestSplit(data, 0.2, rng)
	fmt.Printf("Train len %v, test len %v\n", train.Len(), test.Len())

	// Instantiate the model.
	model := sbr.NewImplicitLSTMModel(train.NumItems())

	// Set the hyperparameters.
	model.ItemEmbeddingDim = 32
	model.LearningRate = 0.16
	model.L2Penalty = 0.0004
	model.NumEpochs = 10
	model.NumThreads = 1

	// Set random seed
	var randomSeed [16]byte
	for idx := range randomSeed {
		randomSeed[idx] = 42
	}
	model.RandomSeed = randomSeed

	// Fit the model.
	fmt.Printf("Fitting the model...\n")
	loss, err := model.Fit(&train)
	if err != nil {
		panic(err)
	}

	// And evaluate.
	fmt.Printf("Evaluating the model...\n")
	mrr, err := model.MRRScore(&test)
	if err != nil {
		panic(err)
	}
	fmt.Printf("Loss %v, MRR: %v\n", loss, mrr)

Installation

Run

go get github.com/maciejkula/sbr-go

followed by

make

in the installation directory. This will download the package's native dependencies. On both OSX and Linux, the resulting binaries are fully statically linked, and you can deploy them like any other Go binary.

If you prefer to build the dependencies from source, run make source instead.

More Repositories

1

spotlight

Deep recommender models using PyTorch.
Python
2,857
star
2

glove-python

Toy Python implementation of http://www-nlp.stanford.edu/projects/glove/
Python
1,232
star
3

rustlearn

Machine learning crate for Rust
Rust
598
star
4

triplet_recommendations_keras

An example of doing MovieLens recommendations using triplet loss in Keras
Jupyter Notebook
417
star
5

wyrm

Autodifferentiation package in Rust.
Rust
169
star
6

sbr-rs

Deep recommender systems for Rust
Rust
115
star
7

netrex

Neural network recommendation models in PyTorch
Python
57
star
8

recommender_datasets

A common format and repository for various recommender datasets.
Python
38
star
9

mixture

TeX
26
star
10

python-rustlearn

Calling rustlearn from Python
Python
26
star
11

explicit-vs-implicit

An experiment on explicit vs implicit feedback recommenders
Jupyter Notebook
26
star
12

binge

Recommendation models that use binary rather than floating point operations at prediction time.
TeX
21
star
13

fizzbuzz

A FizzBuzz solver using a Rust autodifferentiation library.
Rust
20
star
14

dictionarylearning

Online learning of sparse dictionaries
Java
13
star
15

dynarray

Dynamic Numpy arrays
Python
13
star
16

hugo-blog

Rust
8
star
17

BayesianTestJS

Rudimentary Bayesian Beta-Bernoulli A/B testing inference and visualization code.
JavaScript
6
star
18

BetaJS

Beta distribution probability density function (PDF) for JavaScript
JavaScript
3
star
19

sbr-sys

Rust
2
star
20

spotlight-recipe

Conda recipes for Spotlight
Shell
2
star
21

blas_cython

Python
1
star
22

lightfm_datasets

Datasets for the LightFM package
Python
1
star
23

sketchy

Python
1
star
24

wheedle

Rust
1
star
25

fictional-octo-chainsaw

1
star