/**
  * Send the query to PredictionIO engine for product data set
  *
  * @param array $productIds
  * @param array $categories
  * @param array $whitelist
  * @param array $blacklist
  * @return array|bool
  */
 public function sendQuery(array $productIds, array $categories = [], array $whitelist = [], array $blacklist = [])
 {
     try {
         $data = ['items' => $productIds, 'num' => (int) $this->_config->getProductCount(Config::COMPLEMENTARY_PRODUCT_COUNT)];
         return $this->_engineClient->sendQuery($data);
     } catch (\Exception $e) {
         $this->_logger->addCritical($e);
     }
     return false;
 }
 /**
  * Send the query to PredictionIO engine for product data set
  *
  * @param array $productIds
  * @param array $categories
  * @param array $whitelist
  * @param array $blacklist
  * @return array|bool
  */
 public function sendQuery(array $productIds, array $categories = [], array $whitelist = [], array $blacklist = [])
 {
     try {
         $data = ['items' => $productIds, 'num' => (int) $this->_config->getProductCount(Config::SIMILARITY_PRODUCT_COUNT)];
         $this->_addProperties('categories', $data, $categories);
         $this->_addProperties('whitelist', $data, $whitelist);
         $this->_addProperties('blacklist', $data, $blacklist);
         return $this->_engineClient->sendQuery($data);
     } catch (\Exception $e) {
         $this->_logger->addCritical($e);
     }
     return false;
 }
Beispiel #3
0
 public function sendQuery($data = [])
 {
     $client = new EngineClient('http://localhost:8000');
     return $client->sendQuery($data);
 }
<?php

require_once "vendor/autoload.php";
use predictionio\EngineClient;
$client = new EngineClient();
$response = $client->getStatus();
//echo $response;
// Rank item 1 to 5 for each user
for ($i = 1; $i <= 10; $i++) {
    $response = $client->sendQuery(array('uid' => $i, 'iids' => array(1, 2, 3, 4, 5)));
    print_r($response);
}