php - Pseudo-Apriori Algorithm
I have an array of objects with an ID attribute, and I need to link them together in a table.
I would like to insert the object IDs linked together into a 2-column MySQL table.
The table in question has 2 columns: A, and B. I want to link together the collection of objects without any overlap.
I am referring to it as pseudo-apriori because it resembles the candidate-generation process of the apriori algorithm.
For the example below, I have a five objects with an ID value of 1-5. So for example:$obj1->id == 1
, and so on.
Example table:
Input IDs:
{1, 2, 3, 4, 5}
Output DB Table:
Answer
Answer
Answer
Solution:
Really don't know what you're trying to do. But if the result must be as the table example, then you can do it with the following loop:
Here is an jsFiddle example for the output: JsFiddle
Answer
Solution:
E.g. the pear package Math_Combinatorics can do this.
prints
Answer
Solution:
please visit this address: Apriori Algorithm in PHP
Methods: setMaxScan(int), setMinSup(int), setMinConf(int), setDelimiter(string), getMinSup(void), getMinConf(void), getMaxScan(void), getDelimiter(void), process(string or array), printFreqItemsets(void), getFreqItemsets(void), printAssociationRules(void), getAssociationRules(void), saveFreqItemsets(string), saveAssociationRules(string)