Introduction
PHP implementation of the (Weighted Slopeone,Cosine, Weighted Cosine) rating-based collaborative filtering schemes.
Usage
OpenCF Package is designed to be very simple and straightforward to use. All you have to do is:
Load a training set (dataset)
Predict future ratings using a recommender. (Weighted Slopeone,Cosine, Weighted Cosine)
Create Recommender Service
The OpenCF
recommender service is created by direct instantiation:
use OpenCF\RecommenderService;
// Training Dataset
$dataset = [
"squid" => [
"user1" => 1,
"user2" => 1,
"user3" => 0.2,
],
"cuttlefish" => [
"user1" => 0.5,
"user3" => 0.4,
"user4" => 0.9,
],
"octopus" => [
"user1" => 0.2,
"user2" => 0.5,
"user3" => 1,
"user4" => 0.4,
],
"nautilus" => [
"user2" => 0.2,
"user3" => 0.4,
"user4" => 0.5,
],
];
// Create a recommender service instance
$recommenderService = new RecommenderService($dataset);
// Retrieve a recommender (Weighted Slopeone)
$recommender = $recommenderService->weightedSlopeone();
// Predict future ratings
$results = $recommender->predict([
"squid" => 0.4
]);
This should produce the following results:
[
"cuttlefish" => 0.25,
"octopus" => 0.23,
"nautilus" => 0.1
];