diff options
author | RJ Nowling <rnowling@gmail.com> | 2015-01-08 15:03:43 -0800 |
---|---|---|
committer | Xiangrui Meng <meng@databricks.com> | 2015-01-08 15:03:43 -0800 |
commit | c9c8b219ad81c4c30bc1598ff35b01f964570c29 (patch) | |
tree | d9d7aa3396e35e86cabbaaa78d88a65e8e3321c5 /mllib | |
parent | a00af6bec57b8df8b286aaa5897232475aef441c (diff) | |
download | spark-c9c8b219ad81c4c30bc1598ff35b01f964570c29.tar.gz spark-c9c8b219ad81c4c30bc1598ff35b01f964570c29.tar.bz2 spark-c9c8b219ad81c4c30bc1598ff35b01f964570c29.zip |
[SPARK-4891][PySpark][MLlib] Add gamma/log normal/exp dist sampling to P...
...ySpark MLlib
This is a follow up to PR3680 https://github.com/apache/spark/pull/3680 .
Author: RJ Nowling <rnowling@gmail.com>
Closes #3955 from rnowling/spark4891 and squashes the following commits:
1236a01 [RJ Nowling] Fix Python style issues
7a01a78 [RJ Nowling] Fix Python style issues
174beab [RJ Nowling] [SPARK-4891][PySpark][MLlib] Add gamma/log normal/exp dist sampling to PySpark MLlib
Diffstat (limited to 'mllib')
-rw-r--r-- | mllib/src/main/scala/org/apache/spark/mllib/api/python/PythonMLLibAPI.scala | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/mllib/src/main/scala/org/apache/spark/mllib/api/python/PythonMLLibAPI.scala b/mllib/src/main/scala/org/apache/spark/mllib/api/python/PythonMLLibAPI.scala index c4e5fd8e46..555da8c7e7 100644 --- a/mllib/src/main/scala/org/apache/spark/mllib/api/python/PythonMLLibAPI.scala +++ b/mllib/src/main/scala/org/apache/spark/mllib/api/python/PythonMLLibAPI.scala @@ -625,6 +625,21 @@ class PythonMLLibAPI extends Serializable { } /** + * Java stub for Python mllib RandomRDDGenerators.logNormalRDD() + */ + def logNormalRDD(jsc: JavaSparkContext, + mean: Double, + std: Double, + size: Long, + numPartitions: java.lang.Integer, + seed: java.lang.Long): JavaRDD[Double] = { + val parts = getNumPartitionsOrDefault(numPartitions, jsc) + val s = getSeedOrDefault(seed) + RG.logNormalRDD(jsc.sc, mean, std, size, parts, s) + } + + + /** * Java stub for Python mllib RandomRDDGenerators.poissonRDD() */ def poissonRDD(jsc: JavaSparkContext, @@ -638,6 +653,33 @@ class PythonMLLibAPI extends Serializable { } /** + * Java stub for Python mllib RandomRDDGenerators.exponentialRDD() + */ + def exponentialRDD(jsc: JavaSparkContext, + mean: Double, + size: Long, + numPartitions: java.lang.Integer, + seed: java.lang.Long): JavaRDD[Double] = { + val parts = getNumPartitionsOrDefault(numPartitions, jsc) + val s = getSeedOrDefault(seed) + RG.exponentialRDD(jsc.sc, mean, size, parts, s) + } + + /** + * Java stub for Python mllib RandomRDDGenerators.gammaRDD() + */ + def gammaRDD(jsc: JavaSparkContext, + shape: Double, + scale: Double, + size: Long, + numPartitions: java.lang.Integer, + seed: java.lang.Long): JavaRDD[Double] = { + val parts = getNumPartitionsOrDefault(numPartitions, jsc) + val s = getSeedOrDefault(seed) + RG.gammaRDD(jsc.sc, shape, scale, size, parts, s) + } + + /** * Java stub for Python mllib RandomRDDGenerators.uniformVectorRDD() */ def uniformVectorRDD(jsc: JavaSparkContext, @@ -664,6 +706,22 @@ class PythonMLLibAPI extends Serializable { } /** + * Java stub for Python mllib RandomRDDGenerators.logNormalVectorRDD() + */ + def logNormalVectorRDD(jsc: JavaSparkContext, + mean: Double, + std: Double, + numRows: Long, + numCols: Int, + numPartitions: java.lang.Integer, + seed: java.lang.Long): JavaRDD[Vector] = { + val parts = getNumPartitionsOrDefault(numPartitions, jsc) + val s = getSeedOrDefault(seed) + RG.logNormalVectorRDD(jsc.sc, mean, std, numRows, numCols, parts, s) + } + + + /** * Java stub for Python mllib RandomRDDGenerators.poissonVectorRDD() */ def poissonVectorRDD(jsc: JavaSparkContext, @@ -677,6 +735,36 @@ class PythonMLLibAPI extends Serializable { RG.poissonVectorRDD(jsc.sc, mean, numRows, numCols, parts, s) } + /** + * Java stub for Python mllib RandomRDDGenerators.exponentialVectorRDD() + */ + def exponentialVectorRDD(jsc: JavaSparkContext, + mean: Double, + numRows: Long, + numCols: Int, + numPartitions: java.lang.Integer, + seed: java.lang.Long): JavaRDD[Vector] = { + val parts = getNumPartitionsOrDefault(numPartitions, jsc) + val s = getSeedOrDefault(seed) + RG.exponentialVectorRDD(jsc.sc, mean, numRows, numCols, parts, s) + } + + /** + * Java stub for Python mllib RandomRDDGenerators.gammaVectorRDD() + */ + def gammaVectorRDD(jsc: JavaSparkContext, + shape: Double, + scale: Double, + numRows: Long, + numCols: Int, + numPartitions: java.lang.Integer, + seed: java.lang.Long): JavaRDD[Vector] = { + val parts = getNumPartitionsOrDefault(numPartitions, jsc) + val s = getSeedOrDefault(seed) + RG.gammaVectorRDD(jsc.sc, shape, scale, numRows, numCols, parts, s) + } + + } /** |