• Stars
    star
    2,857
  • Rank 15,209 (Top 0.4 %)
  • Language
    Python
  • License
    MIT License
  • Created almost 7 years ago
  • Updated 12 months ago

Reviews

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

Repository Details

Deep recommender models using PyTorch.

image


image

image

image

image

image

image

Spotlight uses PyTorch to build both deep and shallow recommender models. By providing both a slew of building blocks for loss functions (various pointwise and pairwise ranking losses), representations (shallow factorization representations, deep sequence models), and utilities for fetching (or generating) recommendation datasets, it aims to be a tool for rapid exploration and prototyping of new recommender models.

See the full documentation for details.

Installation

conda install -c maciejkula -c pytorch spotlight

Usage

Factorization models

To fit an explicit feedback model on the MovieLens dataset:

from spotlight.cross_validation import random_train_test_split
from spotlight.datasets.movielens import get_movielens_dataset
from spotlight.evaluation import rmse_score
from spotlight.factorization.explicit import ExplicitFactorizationModel

dataset = get_movielens_dataset(variant='100K')

train, test = random_train_test_split(dataset)

model = ExplicitFactorizationModel(n_iter=1)
model.fit(train)

rmse = rmse_score(model, test)

To fit an implicit ranking model with a BPR pairwise loss on the MovieLens dataset:

from spotlight.cross_validation import random_train_test_split
from spotlight.datasets.movielens import get_movielens_dataset
from spotlight.evaluation import mrr_score
from spotlight.factorization.implicit import ImplicitFactorizationModel

dataset = get_movielens_dataset(variant='100K')

train, test = random_train_test_split(dataset)

model = ImplicitFactorizationModel(n_iter=3,
                                   loss='bpr')
model.fit(train)

mrr = mrr_score(model, test)

Sequential models

Recommendations can be seen as a sequence prediction task: given the items a user has interacted with in the past, what will be the next item they will interact with? Spotlight provides a range of models and utilities for fitting next item recommendation models, including

from spotlight.cross_validation import user_based_train_test_split
from spotlight.datasets.synthetic import generate_sequential
from spotlight.evaluation import sequence_mrr_score
from spotlight.sequence.implicit import ImplicitSequenceModel

dataset = generate_sequential(num_users=100,
                              num_items=1000,
                              num_interactions=10000,
                              concentration_parameter=0.01,
                              order=3)

train, test = user_based_train_test_split(dataset)

train = train.to_sequence()
test = test.to_sequence()

model = ImplicitSequenceModel(n_iter=3,
                              representation='cnn',
                              loss='bpr')
model.fit(train)

mrr = sequence_mrr_score(model, test)

Datasets

Spotlight offers a slew of popular datasets, including Movielens 100K, 1M, 10M, and 20M. It also incorporates utilities for creating synthetic datasets. For example, generate_sequential generates a Markov-chain-derived interaction dataset, where the next item a user chooses is a function of their previous interactions:

from spotlight.datasets.synthetic import generate_sequential

# Concentration parameter governs how predictable the chain is;
# order determins the order of the Markov chain.
dataset = generate_sequential(num_users=100,
                              num_items=1000,
                              num_interactions=10000,
                              concentration_parameter=0.01,
                              order=3)

Examples

  1. Rating prediction on the Movielens dataset.
  2. Using causal convolutions for sequence recommendations.
  3. Bloom embedding layers.

How to cite

Please cite Spotlight if it helps your research. You can use the following BibTeX entry:

@misc{kula2017spotlight,
  title={Spotlight},
  author={Kula, Maciej},
  year={2017},
  publisher={GitHub},
  howpublished={\url{https://github.com/maciejkula/spotlight}},
}

Contributing

Spotlight is meant to be extensible: pull requests are welcome. Development progress is tracked on Trello: have a look at the outstanding tickets to get an idea of what would be a useful contribution.

We accept implementations of new recommendation models into the Spotlight model zoo: if you've just published a paper describing your new model, or have an implementation of a model from the literature, make a PR!

More Repositories

1

glove-python

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

rustlearn

Machine learning crate for Rust
Rust
598
star
3

triplet_recommendations_keras

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

wyrm

Autodifferentiation package in Rust.
Rust
169
star
5

sbr-go

Recommender systems for Go
Go
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

spotlight-recipe

Conda recipes for Spotlight
Shell
2
star
20

sbr-sys

Rust
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