PHP code example of rustem-kaimolla / recommender-php

1. Go to this page and download the library: Download rustem-kaimolla/recommender-php 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/ */

    

rustem-kaimolla / recommender-php example snippets




ecommender\Recommender;
use Recommender\Storage\InMemoryStorage;
use Recommender\Similarity\JaccardSimilarity;

$storage = new InMemoryStorage();
$similarity = new JaccardSimilarity();
$recommender = new Recommender($storage, $similarity);

$recommender->addInteraction(1, 10);
$recommender->addInteraction(1, 12);
$recommender->addInteraction(2, 10);
$recommender->addInteraction(2, 11);
$recommender->addInteraction(3, 11);

$recommendations = $recommender->recommendForUser(1, 3);

print_r($recommendations);

Array
(
    [0] => Array
        (
            [item_id] => 11
            [score] => 0.5
        )
)
bash
composer 
bash
git clone https://github.com/rustem-kaimolla/recommender-php.git
cd recommender-php
composer install