pub trait RecommendationEngine: Debug {
// Required methods
fn recommend(
&self,
user_id: usize,
n_items: usize,
exclude_seen: bool,
) -> Result<Vec<Recommendation>>;
fn update(
&mut self,
user_id: usize,
item_id: usize,
rating: f64,
) -> Result<()>;
fn compute_similarity(
&self,
id1: usize,
id2: usize,
similarity_type: SimilarityType,
) -> Result<f64>;
fn parameters(&self) -> &Array1<f64>;
fn clone_box(&self) -> Box<dyn RecommendationEngine>;
}Expand description
Item features
Required Methods§
Sourcefn recommend(
&self,
user_id: usize,
n_items: usize,
exclude_seen: bool,
) -> Result<Vec<Recommendation>>
fn recommend( &self, user_id: usize, n_items: usize, exclude_seen: bool, ) -> Result<Vec<Recommendation>>
Generate recommendations for a user
Sourcefn update(&mut self, user_id: usize, item_id: usize, rating: f64) -> Result<()>
fn update(&mut self, user_id: usize, item_id: usize, rating: f64) -> Result<()>
Update model with new interaction
Sourcefn compute_similarity(
&self,
id1: usize,
id2: usize,
similarity_type: SimilarityType,
) -> Result<f64>
fn compute_similarity( &self, id1: usize, id2: usize, similarity_type: SimilarityType, ) -> Result<f64>
Compute similarity between users or items
Sourcefn parameters(&self) -> &Array1<f64>
fn parameters(&self) -> &Array1<f64>
Get model parameters
Sourcefn clone_box(&self) -> Box<dyn RecommendationEngine>
fn clone_box(&self) -> Box<dyn RecommendationEngine>
Clone the engine