An implementation of sequence recommenders based on the wyrm autdifferentiaton library.
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.
You can fit a model on the Movielens 100K dataset in about 10 seconds:
```rust let mut data = sbr::datasets::downloadmovielens100k().unwrap();
let mut rng = rand::XorShiftRng::from_seed([42; 16]);
let (train, test) = sbr::data::userbasedsplit(&mut data, &mut rng, 0.2); let trainmat = train.tocompressed(); let testmat = test.tocompressed();
println!("Train: {}, test: {}", train.len(), test.len());
let mut model = sbr::models::lstm::Hyperparameters::new(data.numitems(), 32) .embeddingdim(32) .learningrate(0.16) .l2penalty(0.0004) .lstmvariant(sbr::models::lstm::LSTMVariant::Normal) .loss(sbr::models::lstm::Loss::WARP) .optimizer(sbr::models::lstm::Optimizer::Adagrad) .numepochs(10) .rng(rng) .build();
let start = Instant::now(); let loss = model.fit(&trainmat).unwrap(); let elapsed = start.elapsed(); let trainmrr = sbr::evaluation::mrrscore(&model, &trainmat).unwrap(); let testmrr = sbr::evaluation::mrrscore(&model, &test_mat).unwrap();
println!( "Train MRR {} at loss {} and test MRR {} (in {:?})", trainmrr, loss, testmrr, elapsed ); ```
License: MIT