1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate itertools;
#[cfg(test)]
extern crate csv;
#[macro_use]
extern crate failure;
extern crate ndarray;
extern crate rand;
extern crate rayon;
extern crate serde;
extern crate siphasher;
extern crate wyrm;
pub mod data;
pub mod evaluation;
pub mod models;
pub type UserId = usize;
pub type ItemId = usize;
pub type Timestamp = usize;
#[derive(Debug, Fail)]
pub enum PredictionError {
#[fail(display = "Invalid prediction value: non-finite or not a number.")]
InvalidPredictionValue,
}
pub trait OnlineRankingModel {
type UserRepresentation: std::fmt::Debug;
fn user_representation(
&self,
item_ids: &[ItemId],
) -> Result<Self::UserRepresentation, PredictionError>;
fn predict(
&self,
user: &Self::UserRepresentation,
item_ids: &[ItemId],
) -> Result<Vec<f32>, PredictionError>;
}