PHPackages                             feraiur/recommender\_system\_php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. feraiur/recommender\_system\_php

ActivePackage[Utility &amp; Helpers](/categories/utility)

feraiur/recommender\_system\_php
================================

Collaborative Recommender Filtering and Apriori Rules Associations for PHP language

09PHP

Since Aug 13Pushed 5y ago1 watchersCompare

[ Source](https://github.com/fersandev/recommender_system_php)[ Packagist](https://packagist.org/packages/feraiur/recommender_system_php)[ RSS](/packages/feraiur-recommender-system-php/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Recommender System Library with PHP
===================================

[](#recommender-system-library-with-php)

Recommender for PHP is a library that allows to create recommendations based on:

- Collarative Filtering.
- Apriori association rules.

How To
------

[](#how-to)

Include the library using composer and then use the example below:

```
include __DIR__.'/vendor/autoload.php';

use feraiur\recommender_system_php\Predictor;
use feraiur\recommender_system_php\AssociationRules;

// Collaborative Filering

$predictor = new Predictor();
$dataseRatings = [
                [1, 1, 3],
                [2, 2, 5],
                [3, 3, 5],
                [4, 4, 5],
                [5, 5, 5],
                [2, 1, 2],
                [3, 1, 2],
                [4, 1, 2],
                [5, 1, 2],
              ];

try {
    $predictor->setDataset($dataseRatings);
    $recommendations = $predictor->predict();
} catch(Exception $e) {
    var_dump($e->getMessage());
    $recommendations = [];
}

echo("Recommendations:");
echo("Some recommendations for users about items.");
var_dump($recommendations);

// Association Rules

$associationRules = new AssociationRules(20, 50);
$datasetTransactions = [
                [1, 3],
                [3, 1],
                [2, 3],
                [3, 4],
                ["i1", 4],
                ["i2", 4],
                [1, 4],
                ["i2", 3],
                ["i2", 3, 4],
                ["i2", 3, "i1"],
              ];

try {
    $associationRules->setDataset($datasetTransactions);
    $supportsK1 = $associationRules->removeUnwantedSupports($associationRules->getSupports());
    $supportsK2 = $associationRules->removeUnwantedSupports($associationRules->getK2Supports($associationRules->getItemsetsWithK2($supportsK1)));
    $finalPairsItemsets = $associationRules->getFinalPairsItemsets($supportsK2);
    $confidenceRules = $associationRules->getConfidenceRules($finalPairsItemsets, $supportsK2, $supportsK1);

} catch(Exception $e) {
    var_dump($e->getMessage());
    $rules = [];
}

echo("Associations Rules:");
echo("Ex: People who has item {A} has item {B} too.");
var_dump($confidenceRules);

```

Datasets format
===============

[](#datasets-format)

- Dataset for rating predictions should be an array with 3 integer columns: user\_id, item\_id and rating value. (Items shuld not be duplicated for the same user).
- Dataset for apriori rules should be an array that contain another array of item ids. (Items should not be duplicated inside the array of each transaction)

Author
------

[](#author)

Eng. Fernando Sánchez

Unit Test Battery
-----------------

[](#unit-test-battery)

The unit tests battery is inside the folder "/tests"

- Run `php phpunit.phar --verbose RecommendationTest.php`

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity33

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/7a615675e39b2952b9cdd71e242cc6cda87408fcd9c289568a5bca93d142251b?d=identicon)[feraiur](/maintainers/feraiur)

---

Top Contributors

[![fernandoanchez](https://avatars.githubusercontent.com/u/167958131?v=4)](https://github.com/fernandoanchez "fernandoanchez (3 commits)")

### Embed Badge

![Health badge](/badges/feraiur-recommender-system-php/health.svg)

```
[![Health](https://phpackages.com/badges/feraiur-recommender-system-php/health.svg)](https://phpackages.com/packages/feraiur-recommender-system-php)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
