Giter Club home page Giter Club logo

tigocaval / recommendation-algorithm Goto Github PK

View Code? Open in Web Editor NEW
73.0 3.0 13.0 38 KB

Collaborative filtering recommendation system. Recommendation algorithm using collaborative filtering. Topics: Ranking algorithm, euclidean distance algorithm, slope one algorithm, filtragem colaborativa.

Home Page: https://youtu.be/ArGWGn3w788

License: MIT License

PHP 100.00%
collaborative-filtering recommender-system euclidean-algorithm ranking-algorithm recommendation-algorithm php slope-one recommender

recommendation-algorithm's Introduction

Recommendation algorithm

Collaborative filtering recommendation system

  • Ranking algorithm using likes / dislikes or star-based rating
  • This package can be used in any PHP application or with any framework.
  • Download package: composer require tigo/recommendation
  • MIT license. Feel free to use this project. Leave a star ⭐ or make a fork !

If you found this project useful, consider making a donation to support the developer.

paypal | paypal

Getting started

Starting with composer

  1. Install composer
  2. Download package: composer require tigo/recommendation
  3. PHP >= 7.0; Versions that have been tested: 7.2.25, 7.3.23 e 8.0.1.
//Somewhere in your project, you may need to use autoload
include __DIR__ ."/vendor/autoload.php";

Algorithms

  • ranking
  • euclidean
  • slope one

Introduction

Recommend a product using collaborative filtering

   /**  
     $table gets the array from the database.
     $user is the foreign key that represents the user who will receive the recommendation.
   **/
   use Tigo\Recommendation\Recommend; // import class
   $client = new Recommend();
   $client->ranking($table,$user); //optional third parameter refers to the score not accepted
   $client->euclidean($table,$user); //optional third parameter refers to the minimum accepted score
   $client->slopeOne($table, $user); //optional third parameter refers to the minimum accepted score

Configuration

Sometimes, it may be necessary to rename the value of the constants (According to your database table).

example

  • Configure: standard key (Directory: ./src/configuration/StandardKey.php)
    const SCORE = 'score'; //score  
    const PRODUCT_ID = 'product_id'; //Foreign key
    const USER_ID = 'user_id'; //Foreign key 

Example

A simple didactic demonstration of the algorithm

  /**
     Example using "rating: liked and disliked"
     like: score = 1;  dislike: score = 0
  **/
   $table = [
        ['product_id'=> 'A',
         'score'=> 1, 
         'user_id'=> 'Pedro'
        ],
        ['product_id'=> 'B',
         'score'=> 1, 
         'user_id'=> 'Pedro'
        ],
        ['product_id'=> 'A',
         'score'=> 1, 
         'user_id'=> 'João'
        ],
        ['product_id'=> 'B',
         'score'=> 1, 
         'user_id'=> 'João'
        ],
        ['product_id'=> 'C',
         'score'=> 1, 
         'user_id'=> 'João'
        ]
  ];
  use Tigo\Recommendation\Recommend; // import class
  $client = new Recommend();
  print_r($client->ranking($table,"Pedro")); // result = ['C' => 2] 
  print_r($client->ranking($table,"Pedro",1)); // result = []; 
  
  print_r($client->euclidean($table,"Pedro")); // result = ['C' => 1]
  print_r($client->euclidean($table,"Pedro", 2)); // result = [] ;  
  
  print_r($client->slopeOne($table,'Pedro')); // result = ['C' => 1]
  print_r($client->slopeOne($table,'Pedro', 2)); // result = []

Supporting this project

If you are interested in supporting this project, you can help in many ways. Leave a star ⭐ or make a donation of any value.

Sponsor supporting this project

  • []

Contributors

License

MIT license. See the archive License


Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.