PHPackages                             codedheartinside/apriori - 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. codedheartinside/apriori

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

codedheartinside/apriori
========================

Apriori data analysing algorithm written within PHP.

1.1.4(3y ago)1122.4k↓51.1%4[9 issues](https://github.com/codedheartinside/php-apriori/issues)MITPHPPHP &gt;=5.5 || 7.\* || &gt;= 8.1

Since Dec 7Pushed 3y ago1 watchersCompare

[ Source](https://github.com/codedheartinside/php-apriori)[ Packagist](https://packagist.org/packages/codedheartinside/apriori)[ Docs](https://github.com/codedheartinside/php-apriori.git)[ RSS](/packages/codedheartinside-apriori/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (3)Dependencies (1)Versions (10)Used By (0)

PHP Apriori
===========

[](#php-apriori)

[![Run Unit Tests](https://github.com/codedheartinside/php-apriori/actions/workflows/unit_tests.yml/badge.svg)](https://github.com/codedheartinside/php-apriori/actions/workflows/unit_tests.yml)

This package is meant for implementing the Apriori algorithm as a microservice.

Installation:
=============

[](#installation)

Enable composer in your project
-------------------------------

[](#enable-composer-in-your-project)

```
curl -s http://getcomposer.org/installer | php
```

Add the package to your composer.json file

```
{
    "require": {
        "codedheartinside/apriori": "1.*"
    }
}

```

Load the files and create the autoload file
-------------------------------------------

[](#load-the-files-and-create-the-autoload-file)

Download the files

```
php composer.phar install
```

Add the autoloader for the files into your project

```
require 'vendor/autoload.php';
```

Set up the running environment
------------------------------

[](#set-up-the-running-environment)

To set up the running environment for the package, run the installer

```
$installer = new \CodedHeartInside\DataMining\Apriori\Installer();
$installer->createRunningEnvironment();
```

Usage
=====

[](#usage)

Configuration
-------------

[](#configuration)

You first need to create a configuration with the rules for the algorithm

```
$aprioriConfiguration = new \CodedHeartInside\DataMining\Apriori\Configuration();

// Configuring the boundries is optional
$aprioriConfiguration->setDisplayDebugInformation();
$aprioriConfiguration->setMinimumThreshold(2) // Default is 2
    ->setMinimumSupport(0.2) // Default is 0.1
    ->setMinimumConfidence(5) // Default is 0.2
;
```

Defining the data set
---------------------

[](#defining-the-data-set)

After that, all is set to run the algorithm on a data set. The data set can be added through the addDataSet function.

```
$dataSet = array(
    array(1, 3, 4),
    array(2, 4, 6),
    array(1, 2),
    array(5),
);

$dataInput = new \CodedHeartInside\DataMining\Apriori\Data\Input($aprioriConfiguration);
$dataInput->flushDataSet()
    ->addDataSet($dataSet)
    ->addDataSet($dataSet) // In this case, the data set is added twice to create more testing data
;
```

Running the algorithm
---------------------

[](#running-the-algorithm)

To run the the algorithm on the data set, provide the Apriori class with the configuration and call the run function.

```
$aprioriClass = new \CodedHeartInside\DataMining\Apriori\Apriori($aprioriConfiguration);
$aprioriClass->run();
```

Retrieving the data
-------------------

[](#retrieving-the-data)

After running the algorithm, the records with the statistics for support and confidence become retrievable.

**Support is the time a item combination occurs in all of the provided item sets.**

To get the records with the support statistics:

```
foreach ($aprioriClass->getSupportRecords() as $record) {
    print_r($record);
    // Outputs:
    // Array
    // (
    //     [itemIds] => Array
    //     (
    //         [0] => 1
    //         [1] => 4
    //         [2] => 6
    //         [3] => 7
    //     )
    //
    //     [support] => 0.060606060606061
    // )
}
```

**Confidence is the times a article occurs in combination with the other items**

To get the records with the confidence statistics

```
foreach ($aprioriClass->getConfidenceRecords() as $record) {
    print_r($record);
    // Outputs
    // Array
    // (
    //     [if] => Array
    //     (
    //       [0] => 1
    //       [1] => 7
    //     )
    //
    //     [then] => 3
    //     [confidence] => 1
    // )
}
```

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance4

Infrequent updates — may be unmaintained

Popularity34

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity78

Established project with proven stability

 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.

###  Release Activity

Cadence

Every ~436 days

Recently: every ~653 days

Total

7

Last Release

1246d ago

PHP version history (2 changes)1.0.0PHP &gt;=5.5.0

1.1.4PHP &gt;=5.5 || 7.\* || &gt;= 8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/8f959cfb238dc005ef2e5c692f91b68a1371380ff63b14d8b9cdf40d38ce04ab?d=identicon)[codedheartinside](/maintainers/codedheartinside)

---

Top Contributors

[![wimulkeman](https://avatars.githubusercontent.com/u/964346?v=4)](https://github.com/wimulkeman "wimulkeman (64 commits)")

---

Tags

data miningapriori

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/codedheartinside-apriori/health.svg)

```
[![Health](https://phpackages.com/badges/codedheartinside-apriori/health.svg)](https://phpackages.com/packages/codedheartinside-apriori)
```

###  Alternatives

[rubix/ml

A high-level machine learning and deep learning library for the PHP language.

2.2k1.5M28](/packages/rubix-ml)[phabel/phabel

Write and deploy modern PHP 8 code, today.

24660.4k12](/packages/phabel-phabel)[mageprince/module-buynow

Magento2 Buy Now Module

8210.6k](/packages/mageprince-module-buynow)

PHPackages © 2026

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