{"id":16272477,"url":"https://github.com/phpjuice/opencf","last_synced_at":"2025-06-20T22:37:56.490Z","repository":{"id":31842472,"uuid":"271632425","full_name":"phpjuice/opencf","owner":"phpjuice","description":"PHP implementation of the (Weighted Slopeone,Cosine, Weighted Cosine) rating-based collaborative filtering schemes.","archived":false,"fork":false,"pushed_at":"2023-10-05T12:39:37.000Z","size":70,"stargazers_count":96,"open_issues_count":2,"forks_count":7,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-24T10:09:45.360Z","etag":null,"topics":["collaborative-filtering","collaborative-filtering-algorithm","php","recommendation-system","recommender-system"],"latest_commit_sha":null,"homepage":"https://phpjuice.gitbook.io/opencf","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phpjuice.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null}},"created_at":"2020-06-11T19:38:31.000Z","updated_at":"2025-01-09T01:24:41.000Z","dependencies_parsed_at":"2022-08-07T16:31:14.980Z","dependency_job_id":null,"html_url":"https://github.com/phpjuice/opencf","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpjuice%2Fopencf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpjuice%2Fopencf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpjuice%2Fopencf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpjuice%2Fopencf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phpjuice","download_url":"https://codeload.github.com/phpjuice/opencf/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248670508,"owners_count":21142897,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["collaborative-filtering","collaborative-filtering-algorithm","php","recommendation-system","recommender-system"],"created_at":"2024-10-10T18:17:56.452Z","updated_at":"2025-04-13T05:36:51.589Z","avatar_url":"https://github.com/phpjuice.png","language":"PHP","readme":"# OpenCF\n\n[![tests](https://github.com/phpjuice/opencf/actions/workflows/php.yml/badge.svg?branch=main)](https://github.com/phpjuice/opencf/actions/workflows/php.yml)\n[![packagist](https://github.com/phpjuice/opencf/actions/workflows/cron.yml/badge.svg?branch=main)](https://github.com/phpjuice/opencf/actions/workflows/cron.yml)\n[![Maintainability](https://api.codeclimate.com/v1/badges/60b1fac54adddd5a4e12/maintainability)](https://codeclimate.com/github/phpjuice/opencf/maintainability)\n[![Latest Stable Version](http://poser.pugx.org/phpjuice/opencf/v)](https://packagist.org/packages/phpjuice/opencf)\n[![Total Downloads](http://poser.pugx.org/phpjuice/opencf/downloads)](https://packagist.org/packages/phpjuice/opencf)\n[![License](http://poser.pugx.org/phpjuice/opencf/license)](https://packagist.org/packages/phpjuice/opencf)\n\nPHP implementation of the (Weighted Slopeone,Cosine, Weighted Cosine) rating-based collaborative filtering schemes.\n\nTo learn all about it, head over to the extensive [documentation](https://phpjuice.gitbook.io/opencf).\n\n## Installation\n\nOpenCF Package requires `PHP 7.4` or higher.\n\n\u003e **INFO:** If you are using an older version of php this package will not function correctly.\n\nThe supported way of installing `OpenCF` package is via Composer.\n\n```bash\ncomposer require phpjuice/opencf\n```\n\n## Usage\n\nOpenCF Package is designed to be very simple and straightforward to use. All you have to do is:\n\n1. Load a training set (dataset)\n2. Predict future ratings using a recommender. (Weighted Slopeone,Cosine, Weighted Cosine)\n\n### Create Recommender Service\n\nThe `OpenCF` recommender service is created by direct instantiation:\n\n```php\nuse OpenCF\\RecommenderService;\n\n// Create an instance\n$recommenderService = new RecommenderService($dataset);\n```\n\n### Adding dataset\n\nAdding a dataset to the recommender can be done using the constructor or can be easily done by providing an array of\nusers ratings via the `setDataset()` method:\n\n```php\n$dataset = [\n    \"squid\" =\u003e [\n        \"user1\" =\u003e 1,\n        \"user2\" =\u003e 1,\n        \"user3\" =\u003e 0.2,\n    ],\n    \"cuttlefish\" =\u003e [\n        \"user1\" =\u003e 0.5,\n        \"user3\" =\u003e 0.4,\n        \"user4\" =\u003e 0.9,\n    ],\n    \"octopus\" =\u003e [\n        \"user1\" =\u003e 0.2,\n        \"user2\" =\u003e 0.5,\n        \"user3\" =\u003e 1,\n        \"user4\" =\u003e 0.4,\n    ],\n    \"nautilus\" =\u003e [\n        \"user2\" =\u003e 0.2,\n        \"user3\" =\u003e 0.4,\n        \"user4\" =\u003e 0.5,\n    ],\n];\n\n$recommenderService-\u003esetDataset($dataset);\n```\n\n### Getting Predictions\n\nAll you have to do to predict ratings for a new user is to retrieve an engine from the recommender service and \u0026 run\nthe `predict()` method.\n\n```php\n// Get a recommender\n$recommender = $recommenderService-\u003ecosine(); // Cosine recommender\n// OR\n$recommender = $recommenderService-\u003eweightedCosine(); // WeightedCosine recommender\n// OR\n$recommender = $recommenderService-\u003eweightedSlopeone(); // WeightedSlopeone recommender\n\n// Predict future ratings\n$results = $recommender-\u003epredict([\n    \"squid\" =\u003e 0.4\n]);\n```\n\nThis should produce the following results when using `WeightedSlopeone` recommender\n\n```php\n[\n  \"cuttlefish\" =\u003e 0.25,\n  \"octopus\" =\u003e 0.23,\n  \"nautilus\" =\u003e 0.1\n];\n```\n\n## Running the tests\n\nyou can easily run tests using composer\n\n```bash\ncomposer test\n```\n\n## Built With\n\n- [PHP](http://www.php.net) - The programing language used\n- [Composer](https://getcomposer.org) - Dependency Management\n- [Pest](https://pestphp.com) - An elegant PHP Testing Framework\n\n## Changelog\n\nPlease see the [changelog](changelog.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING.md](./CONTRIBUTING.md) for details and a todo list.\n\n## Security\n\nIf you discover any security related issues, please email author instead of using the issue tracker.\n\n## Credits\n\n- [Daniel Lemire](https://github.com/lemire)\n- [SlopeOne Predictors for Online Rating-Based Collaborative Filtering](https://www.researchgate.net/publication/1960789_Slope_One_Predictors_for_Online_Rating-Based_Collaborative_Filtering)\n- [Distance Weighted Cosine Similarity](https://link.springer.com/chapter/10.1007/978-3-642-41278-3_74)\n\n## Versioning\n\nWe use [SemVer](http://semver.org/) for versioning. For the versions available, see\nthe [tags on this repository](https://github.com/PHPJuice/opencf/tags).\n\n## License\n\nlicense. Please see the [Licence](https://github.com/phpjuice/opencf/blob/main/LICENSE) for more information.\n\n[![tests](https://github.com/phpjuice/opencf/actions/workflows/php.yml/badge.svg?branch=main)](https://github.com/phpjuice/opencf/actions/workflows/php.yml)\n[![packagist](https://github.com/phpjuice/opencf/actions/workflows/cron.yml/badge.svg?branch=main)](https://github.com/phpjuice/opencf/actions/workflows/cron.yml)\n[![Maintainability](https://api.codeclimate.com/v1/badges/60b1fac54adddd5a4e12/maintainability)](https://codeclimate.com/github/phpjuice/opencf/maintainability)\n[![Latest Stable Version](http://poser.pugx.org/phpjuice/opencf/v)](https://packagist.org/packages/phpjuice/opencf)\n[![Total Downloads](http://poser.pugx.org/phpjuice/opencf/downloads)](https://packagist.org/packages/phpjuice/opencf)\n[![License](http://poser.pugx.org/phpjuice/opencf/license)](https://packagist.org/packages/phpjuice/opencf)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphpjuice%2Fopencf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphpjuice%2Fopencf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphpjuice%2Fopencf/lists"}