2017 © Pedro Peláez
 

library open-cf

OpenCF - an Item-based Collaborative Filtering Engine.

image

phpjuice/open-cf

OpenCF - an Item-based Collaborative Filtering Engine.

  • Tuesday, May 1, 2018
  • by thesimpledesigners
  • Repository
  • 1 Watchers
  • 2 Stars
  • 10 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 25 % Grown

The README.md

OpenCF

tests packagist Maintainability Latest Stable Version Total Downloads License, (*1)

PHP implementation of the (Weighted Slopeone,Cosine, Weighted Cosine) rating-based collaborative filtering schemes., (*2)

To learn all about it, head over to the extensive documentation., (*3)

Installation

OpenCF Package requires PHP 7.4 or higher., (*4)

INFO: If you are using an older version of php this package will not function correctly., (*5)

The supported way of installing OpenCF package is via Composer., (*6)

composer require phpjuice/opencf

Usage

OpenCF Package is designed to be very simple and straightforward to use. All you have to do is:, (*7)

  1. Load a training set (dataset)
  2. Predict future ratings using a recommender. (Weighted Slopeone,Cosine, Weighted Cosine)

Create Recommender Service

The OpenCF recommender service is created by direct instantiation:, (*8)

use OpenCF\RecommenderService;

// Create an instance
$recommenderService = new RecommenderService($dataset);

Adding dataset

Adding a dataset to the recommender can be done using the constructor or can be easily done by providing an array of users ratings via the setDataset() method:, (*9)

$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,
    ],
];

$recommenderService->setDataset($dataset);

Getting Predictions

All you have to do to predict ratings for a new user is to retrieve an engine from the recommender service and & run the predict() method., (*10)

// Get a recommender
$recommender = $recommenderService->cosine(); // Cosine recommender
// OR
$recommender = $recommenderService->weightedCosine(); // WeightedCosine recommender
// OR
$recommender = $recommenderService->weightedSlopeone(); // WeightedSlopeone recommender

// Predict future ratings
$results = $recommender->predict([
    "squid" => 0.4
]);

This should produce the following results when using WeightedSlopeone recommender, (*11)

[
  "cuttlefish" => 0.25,
  "octopus" => 0.23,
  "nautilus" => 0.1
];

Running the tests

you can easily run tests using composer, (*12)

composer test

Built With

  • PHP - The programing language used
  • Composer - Dependency Management
  • Pest - An elegant PHP Testing Framework

Changelog

Please see the changelog for more information on what has changed recently., (*13)

Contributing

Please see CONTRIBUTING.md for details and a todo list., (*14)

Security

If you discover any security related issues, please email author instead of using the issue tracker., (*15)

Credits

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository., (*16)

License

license. Please see the Licence for more information., (*17)

tests packagist Maintainability Latest Stable Version Total Downloads License, (*18)

The Versions

01/05 2018

dev-master

9999999-dev

OpenCF - an Item-based Collaborative Filtering Engine.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by The Simple Designers

recommendation recommender collaborative filtering