phpjuice/opencf
Composer 安装命令:
composer require phpjuice/opencf
包简介
PHP implementation of the (Weighted Slopeone,Cosine, Weighted Cosine) rating-based collaborative filtering schemes.
关键字:
README 文档
README
PHP implementation of the (Weighted Slopeone,Cosine, Weighted Cosine) rating-based collaborative filtering schemes.
To learn all about it, head over to the extensive documentation.
Installation
OpenCF Package requires PHP 7.4 or higher.
INFO: If you are using an older version of php this package will not function correctly.
The supported way of installing OpenCF package is via Composer.
composer require phpjuice/opencf
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; // 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:
$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.
// 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
[ "cuttlefish" => 0.25, "octopus" => 0.23, "nautilus" => 0.1 ];
Running the tests
you can easily run tests using composer
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.
Contributing
Please see CONTRIBUTING.md for details and a todo list.
Security
If you discover any security related issues, please email author instead of using the issue tracker.
Credits
- Daniel Lemire
- SlopeOne Predictors for Online Rating-Based Collaborative Filtering
- Distance Weighted Cosine Similarity
Versioning
We use SemVer for versioning. For the versions available, see the tags on this repository.
License
license. Please see the Licence for more information.
phpjuice/opencf 适用场景与选型建议
phpjuice/opencf 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5.3k 次下载、GitHub Stars 达 96, 最近一次更新时间为 2022 年 02 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「recommendation」 「recommender」 「collaborative filtering」 「weighted slope one」 「collaborative filtering engine」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 phpjuice/opencf 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 phpjuice/opencf 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 phpjuice/opencf 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
collaborative filtering recommender systems
PHP implementation of the Weighted Slope One rating-based collaborative filtering scheme.
Use MotaWord API to post and track your translation projects.
Wrapping Redis's sorted set APIs for specializing recommending operations.
Simple wiki engine built on Laravel.
Core components for the Recsys PHP payment processing library
统计信息
- 总下载量: 5.3k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 97
- 点击次数: 28
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-02-27