1. Go to this page and download the library: Download quellabs/recommender library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
quellabs / recommender example snippets
// config/recommender.php
return [
// Default category used when no category is passed to engine methods
'category' => 1,
// Minimum number of common ratings before similarity is considered reliable
'threshold_nr_common_ratings' => 30,
// Multiplier used in the similarity confidence calculation
'threshold_mult' => 2,
// Minimum rating for an item to count as "liked" in link calculations
'threshold_rating' => 0.66,
// Cost factor used in the member similarity spread calculation
'cost' => 5.0,
// Sentinel value stored to mark "not interested" (must be negative)
'not_interested' => -1.0,
// Maintain vogoo_links incrementally on every rating change.
// When false, run "sculpt recommender:rebuild-links" after bulk imports.
'direct_links' => false,
'direct_slope' => true,
];
use Quellabs\Recommender\ItemRecommender;
use Quellabs\Recommender\RecommendationEngine;
class ProductController
{
public function __construct(
private RecommendationEngine $engine,
private ItemRecommender $recommender,
) {}
}
use Cake\Database\Connection;
use Cake\Database\Driver\Mysql;
use Quellabs\Recommender\Config\RecommendationConfig;
use Quellabs\Recommender\RecommendationEngine;
use Quellabs\Recommender\ItemRecommender;
$connection = new Connection([
'driver' => Mysql::class,
'host' => 'localhost',
'username' => 'root',
'password' => '',
'database' => 'mydb',
]);
$config = new RecommendationConfig();
$engine = new RecommendationEngine($connection, $config);
$recommender = new ItemRecommender($connection, $config);
$booksConfig = new RecommendationConfig(category: 1);
$moviesConfig = new RecommendationConfig(category: 2);
$booksEngine = new RecommendationEngine($connection, $booksConfig);
$moviesEngine = new RecommendationEngine($connection, $moviesConfig);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.