PHP Class Phpml\Association\Apriori

Inheritance: implements Associator, use trait Phpml\Helper\Trainable, use trait Phpml\Helper\Predictable
Show file Open project: php-ai/php-ml Class Usage Examples

Public Methods

Method Description
__construct ( float $support, float $confidence ) Apriori constructor.
apriori ( ) : array Generates frequent item sets.
getRules ( ) : array Get all association rules which are generated for every k-length frequent item set.

Protected Methods

Method Description
predictSample ( array $sample ) : array

Private Methods

Method Description
antecedents ( array $sample ) : array Generates all proper subsets for given set $sample without the empty set.
candidates ( array $samples ) : array Calculates frequent k item sets, where count($samples) == $k - 1.
confidence ( array $set, array $subset ) : float Calculates confidence for $set. Confidence is the relative amount of sets containing $subset which also contain $set.
contains ( array $system, array $set ) : boolean Returns true if set is an element of system.
equals ( array $set1, array $set2 ) : boolean Returns true if string representation of items does not differ.
frequency ( array $sample ) : integer Counts occurrences of $sample as subset in data pool.
frequent ( array $samples ) : array Returns frequent item sets only.
generateAllRules ( ) Generate rules for each k-length frequent item set.
generateRules ( array $frequent ) Generate confident rules for frequent item set.
items ( ) : array Calculates frequent k = 1 item sets.
powerSet ( array $sample ) : array Generates the power set for given item set $sample.
subset ( array $set, array $subset ) : boolean Returns true if subset is a (proper) subset of set by its items string representation.
support ( array $sample ) : float Calculates support for item set $sample. Support is the relative amount of sets containing $sample in the data pool.

Method Details

__construct() public method

Apriori constructor.
public __construct ( float $support, float $confidence )
$support float
$confidence float

apriori() public method

Generates frequent item sets.
public apriori ( ) : array
return array

getRules() public method

Get all association rules which are generated for every k-length frequent item set.
public getRules ( ) : array
return array

predictSample() protected method

protected predictSample ( array $sample ) : array
$sample array
return array