public function CFRecommender::finalize in Recommender API 7.6
Save data to database, etc.
Return value
mixed any data that should be returned.
Overrides RecommenderInterface::finalize
1 method overrides CFRecommender::finalize()
- ItemBasedRecommender::finalize in classes/
Recommender.php - Save data to database, etc.
File
- classes/
Recommender.php, line 193
Class
- CFRecommender
- This is the classical collaborative filtering implementation.
Code
public function finalize() {
// save user similarities
db_query("DELETE FROM {$this->structure['user similarity']['name']}");
$this
->saveMatrix($this->userMap, $this->userMap, $this->similarityMatrix, $this->structure['user similarity']['name'], $this->structure['user similarity']['user1 field'], $this->structure['user similarity']['user2 field'], $this->structure['user similarity']['score field'], $this->structure['user similarity']['timestamp field'], TRUE);
// save predictions
db_query("DELETE FROM {$this->structure['prediction']['name']}");
$this
->saveMatrix($this->userMap, $this->itemMap, $this->predictionMatrix, $this->structure['prediction']['name'], $this->structure['prediction']['user field'], $this->structure['prediction']['item field'], $this->structure['prediction']['score field'], $this->structure['prediction']['timestamp field']);
// return other data
return array(
'num_user' => $this->userNum,
'num_item' => $this->itemNum,
);
}