# 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 :star: or make a fork !***
*If you found this project useful, consider making a donation to support the developer.*
[![paypal](https://www.paypalobjects.com/pt_BR/BR/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/donate?hosted_button_id=S7FBV5N6ZTRXQ)
|
[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/donate?hosted_button_id=PPDESEV98R8KS)
[![](https://github.com/tigoCaval/images/blob/main/web/recommend.gif)](https://github.com/tigoCaval/recommendation-algorithm)
### 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.
```php
//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
```php
/**
$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](https://github.com/tigoCaval/images/blob/main/web/table_r1.jpg)](https://github.com/tigoCaval/recommendation-algorithm)
- Configure: standard key (Directory: ```./src/configuration/StandardKey.php```)
```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
```php
/**
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 :star: or make a donation of any value.
### Sponsor supporting this project
- []
### Contributors
- [Tiago A C Pereira](https://github.com/tigoCaval)
- [list of contributors](https://github.com/tigoCaval/recommendation-algorithm/graphs/contributors)
### License
MIT license. See the archive [License](https://github.com/tigoCaval/recommendation-algorithm/blob/main/LICENSE)
---
没有合适的资源?快使用搜索试试~ 我知道了~
协同过滤推荐系统。使用协同过滤的推荐算法。主题:排序算法,欧氏距离算法,斜率一算法.zip
共17个文件
php:12个
xml:1个
json:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 163 浏览量
2023-04-23
00:21:42
上传
评论
收藏 14KB ZIP 举报
温馨提示
协同过滤推荐系统。使用协同过滤的推荐算法。主题:排序算法,欧氏距离算法,斜率一算法.zip
资源推荐
资源详情
资源评论
收起资源包目录
协同过滤推荐系统。使用协同过滤的推荐算法。主题:排序算法,欧氏距离算法,斜率一算法,filtragemcolaborativa。.zip (17个子文件)
recommendation-algorithm-main
.github
FUNDING.yml 704B
src
Traits
OperationTrait.php 973B
Interfaces
CollaborativeInterface.php 152B
Factories
CollaborativeFactory.php 543B
Configuration
StandardKey.php 217B
Creator
CollaborativeCreator.php 709B
Collaborative
EuclideanCollaborative.php 4KB
SlopeOneCollaborative.php 4KB
Base.php 1KB
RankingCollaborative.php 3KB
Recommend.php 1KB
LICENSE 1KB
composer.json 819B
tests
RecommendTest.php 3KB
DataArrayTrait.php 2KB
phpunit.xml 339B
README.md 4KB
共 17 条
- 1
资源评论
快撑死的鱼
- 粉丝: 1w+
- 资源: 9156
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功