1. Go to this page and download the library: Download aldeebhasan/laravelcf 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/ */
aldeebhasan / laravelcf example snippets
use \Aldeebhasan\LaravelCF\Facades\Recommender;
Recommender::addRating ('user_1', 'product_1', 5);
Recommender::addCartAddition('user_1', 'product_1', 2); // like the quantity
Recommender::addPurchase ('user_1', 'product_1', 5); // like the quantity
Recommender::addBookmark ('user_1', 'product_1', 5);
use \Aldeebhasan\LaravelCF\Facades\Recommender;
use \Aldeebhasan\LaravelCF\Enums\RelationType;
/* you cann also use any of RelationType::PURCHASE,RelationType::CART_ACTION,RelationType::BOOKMARK*/
Recommender::getItemBasedRecommender(RelationType::RATE); // to recommend similar products
//OR
Recommender::getUserBasedRecommender(RelationType::RATE);// to recommend similar users
use \Aldeebhasan\LaravelCF\Facades\Recommender;
use \Aldeebhasan\LaravelCF\Enums\RelationType;
/* you cann also use any of RelationType::PURCHASE,RelationType::CART_ACTION,RelationType::BOOKMARK*/
Recommender::getItemBasedRecommender(RelationType::RATE)
->setSimilarityFunction(Cosine::class)
->train()
->recommendTo('user_1');
use \Aldeebhasan\LaravelCF\Facades\Recommender;
use \Aldeebhasan\LaravelCF\Enums\RelationType;
use \Aldeebhasan\LaravelCF\Enums\MissingValue;
use \Aldeebhasan\LaravelCF\Similarity;
Recommender::getItemBasedRecommender(RelationType::RATE)
// use Weighted cosine algorithm and replace the missing values with zero
->setSimilarityFunction(CosineWeighted::class,MissingValue::ZERO,true)
// use SlopeOne algorithm and replace the missing values with the mean
->setSimilarityFunction(SlopeOne::class,MissingValue::MEAN,true)