class ItemBasedRecommender in Recommender API 7.6
Hierarchy
- class \CFRecommender implements RecommenderInterface
- class \ItemBasedRecommender
Expanded class hierarchy of ItemBasedRecommender
1 string reference to 'ItemBasedRecommender'
- recommender_process_record in ./
recommender.module - This function process the command, and saves result back to $record. Will not save record.
File
- classes/
Recommender.php, line 216
View source
class ItemBasedRecommender extends CFRecommender {
public function initialize($params) {
// do a simple trick of inverse item/user fields.
parent::initialize($params);
$user_field = $this->structure['preference']['user field'];
$item_field = $this->structure['preference']['item field'];
$this->structure['preference']['user field'] = $item_field;
$this->structure['preference']['item field'] = $user_field;
}
public function finalize() {
// save item similarities
db_query("DELETE FROM {$this->structure['item similarity']['name']}");
$this
->saveMatrix($this->userMap, $this->userMap, $this->similarityMatrix, $this->structure['item similarity']['name'], $this->structure['item similarity']['item1 field'], $this->structure['item similarity']['item2 field'], $this->structure['item similarity']['score field'], $this->structure['item 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']['item field'], $this->structure['prediction']['user field'], $this->structure['prediction']['score field'], $this->structure['prediction']['timestamp field']);
// note: this should be reverse.
return array(
'num_user' => $this->itemNum,
'num_item' => $this->userNum,
);
}
}