Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
docs update
  • Loading branch information
YY-OnCall committed Mar 31, 2017
commit e9b090ac07291de9e09c81a0bb371fffb3384a4f
21 changes: 13 additions & 8 deletions docs/ml-frequent-pattern-mining.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,32 @@ explicitly, which are usually expensive to generate.
After the second step, the frequent itemsets can be extracted from the FP-tree.
In `spark.mllib`, we implemented a parallel version of FP-growth called PFP,
as described in [Li et al., PFP: Parallel FP-growth for query recommendation](http://dx.doi.org/10.1145/1454008.1454027).
PFP distributes the work of growing FP-trees based on the suffices of transactions,
and hence more scalable than a single-machine implementation.
PFP distributes the work of growing FP-trees based on the suffixes of transactions,
and hence is more scalable than a single-machine implementation.
We refer users to the papers for more details.

`spark.ml`'s FP-growth implementation takes the following (hyper-)parameters:

* `minSupport`: the minimum support for an itemset to be identified as frequent.
For example, if an item appears 3 out of 5 transactions, it has a support of 3/5=0.6.
* `minConfidence`: minimum confidence for generating Association Rule. The parameter will not affect the mining
for frequent itemsets,, but specify the minimum confidence for generating association rules from frequent itemsets.
* `minConfidence`: minimum confidence for generating Association Rule. Confidence is an indication of how often an
association rule has been found to be true. For example, if in the transactions itemset `X` appears 4 times, `X`
and `Y` co-occur only 2 times, the confidence for the rule `X => Y` is then 2/4 = 0.5. The parameter will not
affect the mining for frequent itemsets, but specify the minimum confidence for generating association rules
from frequent itemsets.
* `numPartitions`: the number of partitions used to distribute the work. By default the param is not set, and
partition number of the input dataset is used.
number of partitions of the input dataset is used.

The `FPGrowthModel` provides:

* `freqItemsets`: frequent itemsets in the format of DataFrame("items"[Array], "freq"[Long])
* `associationRules`: association rules generated with confidence above `minConfidence`, in the format of
DataFrame("antecedent"[Array], "consequent"[Array], "confidence"[Double]).
* `transform`: The transform method examines the input items in `itemsCol` against all the association rules and
summarize the consequents as prediction. The prediction column has the same data type as the
`itemsCol` and does not contain existing items in the `itemsCol`.
* `transform`: For each transaction in itemsCol, the `transform` method will compare its items against the antecedents
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

itemsCol?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean style it as code with backtick

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure.

of each association rule. If the record contains all the antecedents of a specific association rule, the rule
will be considered as applicable and its consequents will be added to the prediction result. The transform
method will summarize the consequents from all the applicable rules as prediction. The prediction column has
the same data type as `itemsCol` and does not contain existing items in the `itemsCol`.


**Examples**
Expand Down
2 changes: 1 addition & 1 deletion docs/mllib-frequent-pattern-mining.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ explicitly, which are usually expensive to generate.
After the second step, the frequent itemsets can be extracted from the FP-tree.
In `spark.mllib`, we implemented a parallel version of FP-growth called PFP,
as described in [Li et al., PFP: Parallel FP-growth for query recommendation](http://dx.doi.org/10.1145/1454008.1454027).
PFP distributes the work of growing FP-trees based on the suffices of transactions,
PFP distributes the work of growing FP-trees based on the suffixes of transactions,
and hence more scalable than a single-machine implementation.
We refer users to the papers for more details.

Expand Down
9 changes: 6 additions & 3 deletions mllib/src/main/scala/org/apache/spark/ml/fpm/FPGrowth.scala
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,12 @@ class FPGrowthModel private[ml] (

/**
* The transform method first generates the association rules according to the frequent itemsets.
* Then for each association rule, it will examine the input items against antecedents and
* summarize the consequents as prediction. The prediction column has the same data type as the
* input column(Array[T]) and will not contain existing items in the input column. The null
* Then for each transaction in itemsCol, the transform method will compare its items against the
* antecedents of each association rule. If the record contains all the antecedents of a
* specific association rule, the rule will be considered as applicable and its consequents
* will be added to the prediction result. The transform method will summarize the consequents
* from all the applicable rules as prediction. The prediction column has the same data type as
* the input column(Array[T]) and will not contain existing items in the input column. The null
* values in the itemsCol columns are treated as empty sets.
* WARNING: internally it collects association rules to the driver and uses broadcast for
* efficiency. This may bring pressure to driver memory for large set of association rules.
Expand Down