6 releases (3 breaking)

0.4.0 Jun 27, 2018
0.3.0 Jun 19, 2018
0.2.1 Jun 9, 2018
0.1.1 May 24, 2018

#1 in Machine learning

Download history 4/week @ 2018-08-17 9/week @ 2018-08-24 3/week @ 2018-08-31 9/week @ 2018-09-07 3/week @ 2018-09-14 1/week @ 2018-09-21 14/week @ 2018-09-28 12/week @ 2018-10-05 2/week @ 2018-10-12 68/week @ 2018-10-19 1/week @ 2018-10-26 34/week @ 2018-11-02 34/week @ 2018-11-09

299 downloads per month

MIT license

73KB
1.5K SLoC

sbr

Crates.io badge Docs.rs badge Build Status

An implementation of sequence recommenders based on the wyrm autdifferentiaton library.

sbr-rs

sbr implements efficient recommender algorithms which operate on sequences of items: given previous items a user has interacted with, the model will recommend the items the user is likely to interact with in the future.

Example

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

let mut data = sbr::datasets::download_movielens_100k().unwrap();

let mut rng = rand::XorShiftRng::from_seed([42; 16]);

let (train, test) = sbr::data::user_based_split(&mut data, &mut rng, 0.2);
let train_mat = train.to_compressed();
let test_mat = test.to_compressed();

println!("Train: {}, test: {}", train.len(), test.len());

let mut model = sbr::models::lstm::Hyperparameters::new(data.num_items(), 32)
    .embedding_dim(32)
    .learning_rate(0.16)
    .l2_penalty(0.0004)
    .lstm_variant(sbr::models::lstm::LSTMVariant::Normal)
    .loss(sbr::models::lstm::Loss::WARP)
    .optimizer(sbr::models::lstm::Optimizer::Adagrad)
    .num_epochs(10)
    .rng(rng)
    .build();

let start = Instant::now();
let loss = model.fit(&train_mat).unwrap();
let elapsed = start.elapsed();
let train_mrr = sbr::evaluation::mrr_score(&model, &train_mat).unwrap();
let test_mrr = sbr::evaluation::mrr_score(&model, &test_mat).unwrap();

println!(
    "Train MRR {} at loss {} and test MRR {} (in {:?})",
    train_mrr, loss, test_mrr, elapsed
);

License: MIT

Dependencies

~17MB
~365K SLoC