From 85882aeda99e9407fed82fe7fef79adcb8999986 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yan=20Facai=20=28=E9=A2=9C=E5=8F=91=E6=89=8D=29?= Date: Mon, 22 May 2017 15:10:47 +0800 Subject: [PATCH 1/4] ENH: add numPartitions --- python/pyspark/ml/fpm.py | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/python/pyspark/ml/fpm.py b/python/pyspark/ml/fpm.py index b30d4edb1990..249b470ae6e1 100644 --- a/python/pyspark/ml/fpm.py +++ b/python/pyspark/ml/fpm.py @@ -49,6 +49,32 @@ def getMinSupport(self): return self.getOrDefault(self.minSupport) +class HasNumPartitions(Params): + """ + Mixin for param support. + """ + + numPartitions = Param( + Params._dummy(), + "numPartitions", + """Number of partitions (at least 1) used by parallel FP-growth. + By default the param is not set, + and partition number of the input dataset is used.""", + typeConverter=TypeConverters.toInt) + + def setNumPartitions(self, value): + """ + Sets the value of :py:attr:`numPartitions`. + """ + return self._set(numPartitions=value) + + def getNumPartitions(self): + """ + Gets the value of numPartitions or its default value. + """ + return self.getOrDefault(self.numPartitions) + + class HasConfidence(Params): """ Mixin for param confidence. @@ -126,7 +152,8 @@ def associationRules(self): class FPGrowth(JavaEstimator, HasItemsCol, HasPredictionCol, - HasSupport, HasConfidence, JavaMLWritable, JavaMLReadable): + HasSupport, HasNumPartitions, HasConfidence, + JavaMLWritable, JavaMLReadable): """ .. note:: Experimental From 4062273a53653e2594adba3b0a99367c05be6055 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yan=20Facai=20=28=E9=A2=9C=E5=8F=91=E6=89=8D=29?= Date: Thu, 25 May 2017 12:18:27 +0800 Subject: [PATCH 2/4] DOC: revise Mixin description --- python/pyspark/ml/fpm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/pyspark/ml/fpm.py b/python/pyspark/ml/fpm.py index 249b470ae6e1..66b3a51bee8a 100644 --- a/python/pyspark/ml/fpm.py +++ b/python/pyspark/ml/fpm.py @@ -51,7 +51,7 @@ def getMinSupport(self): class HasNumPartitions(Params): """ - Mixin for param support. + Mixin for param numPartitions: Number of partitions (at least 1) used by parallel FP-growth. """ numPartitions = Param( From 0af1516666a25d5cb80e19fda6d51f3aa011e89b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yan=20Facai=20=28=E9=A2=9C=E5=8F=91=E6=89=8D=29?= Date: Thu, 25 May 2017 12:18:45 +0800 Subject: [PATCH 3/4] DOC: add :py:attr: --- python/pyspark/ml/fpm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/pyspark/ml/fpm.py b/python/pyspark/ml/fpm.py index 66b3a51bee8a..c97d949fb285 100644 --- a/python/pyspark/ml/fpm.py +++ b/python/pyspark/ml/fpm.py @@ -70,7 +70,7 @@ def setNumPartitions(self, value): def getNumPartitions(self): """ - Gets the value of numPartitions or its default value. + Gets the value of :py:attr:`numPartitions` or its default value. """ return self.getOrDefault(self.numPartitions) From 44267cb56dafd59fb9a43cd72b18d5c1c2cf0c6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yan=20Facai=20=28=E9=A2=9C=E5=8F=91=E6=89=8D=29?= Date: Thu, 25 May 2017 12:21:16 +0800 Subject: [PATCH 4/4] DOC: replace triple quote --- python/pyspark/ml/fpm.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/python/pyspark/ml/fpm.py b/python/pyspark/ml/fpm.py index c97d949fb285..1290d6898168 100644 --- a/python/pyspark/ml/fpm.py +++ b/python/pyspark/ml/fpm.py @@ -57,9 +57,9 @@ class HasNumPartitions(Params): numPartitions = Param( Params._dummy(), "numPartitions", - """Number of partitions (at least 1) used by parallel FP-growth. - By default the param is not set, - and partition number of the input dataset is used.""", + "Number of partitions (at least 1) used by parallel FP-growth. " + + "By default the param is not set, " + + "and partition number of the input dataset is used.", typeConverter=TypeConverters.toInt) def setNumPartitions(self, value):