You are here

public function ItemBasedRecommender::finalize in Recommender API 7.6

Save data to database, etc.

Return value

mixed any data that should be returned.

Overrides CFRecommender::finalize

File

classes/Recommender.php, line 227

Class

ItemBasedRecommender

Code

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,
  );
}