Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
update docs in scala, python, R
  • Loading branch information
mgaido91 committed Aug 31, 2018
commit 2407e05d4bfbbe71359cf5a57a856ab5514998cb
5 changes: 3 additions & 2 deletions R/pkg/R/mllib_fpm.R
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,11 @@ setMethod("spark.freqItemsets", signature(object = "FPGrowthModel"),
# Get association rules.

#' @return A \code{SparkDataFrame} with association rules.
#' The \code{SparkDataFrame} contains three columns:
#' The \code{SparkDataFrame} contains four columns:
#' \code{antecedent} (an array of the same type as the input column),
#' \code{consequent} (an array of the same type as the input column),
#' and \code{condfidence} (confidence).
#' \code{condfidence} (confidence for the rule)
#' and \code{lift} (lift for the rule)
#' @rdname spark.fpGrowth
#' @aliases associationRules,FPGrowthModel-method
#' @note spark.associationRules(FPGrowthModel) since 2.2.0
Expand Down
10 changes: 5 additions & 5 deletions mllib/src/main/scala/org/apache/spark/ml/fpm/FPGrowth.scala
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,9 @@ class FPGrowthModel private[ml] (
@transient private var _cachedRules: DataFrame = _

/**
* Get association rules fitted using the minConfidence. Returns a dataframe
* with three fields, "antecedent", "consequent" and "confidence", where "antecedent" and
* "consequent" are Array[T] and "confidence" is Double.
* Get association rules fitted using the minConfidence. Returns a dataframe with four fields,
* "antecedent", "consequent", "confidence" and "lift", where "antecedent" and "consequent" are
* Array[T], whereas "confidence" and "lift" are Double.
*/
@Since("2.2.0")
@transient def associationRules: DataFrame = {
Expand Down Expand Up @@ -381,8 +381,8 @@ private[fpm] object AssociationRules {
* @param freqCol column name for appearance count of the frequent itemsets
* @param minConfidence minimum confidence for generating the association rules
* @param itemSupport map containing an item and its support
* @return a DataFrame("antecedent"[Array], "consequent"[Array], "confidence"[Double])
* containing the association rules.
* @return a DataFrame("antecedent"[Array], "consequent"[Array], "confidence"[Double],
* "lift" [Double]) containing the association rules.
*/
def getAssociationRulesFromFP[T: ClassTag](
dataset: Dataset[_],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ object AssociationRules {
@Since("1.5.0")
def confidence: Double = freqUnion / freqAntecedent

/**
* Returns the lift of the rule.
*/
@Since("2.4.0")
def lift: Option[Double] = freqConsequent.map(fCons => confidence / fCons)

Expand Down
3 changes: 2 additions & 1 deletion python/pyspark/ml/fpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,11 @@ def freqItemsets(self):
@since("2.2.0")
def associationRules(self):
"""
DataFrame with three columns:
DataFrame with four columns:
* `antecedent` - Array of the same type as the input column.
* `consequent` - Array of the same type as the input column.
* `confidence` - Confidence for the rule (`DoubleType`).
* `lift` - Lift for the rule (`DoubleType`).
"""
return self._call_java("associationRules")

Expand Down