aboutsummaryrefslogtreecommitdiff
path: root/mllib
diff options
context:
space:
mode:
authorWeichenXu <WeichenXu123@outlook.com>2016-09-23 11:14:22 -0700
committerFelix Cheung <felixcheung@apache.org>2016-09-23 11:14:22 -0700
commitf89808b0fdbc04e1bdff1489a6ec4c84ddb2adc4 (patch)
treed7f2cb9d4e595f02e675b71ff19038fe203e2b1a /mllib
parent90d5754212425d55f992c939a2bc7d9ac6ef92b8 (diff)
downloadspark-f89808b0fdbc04e1bdff1489a6ec4c84ddb2adc4.tar.gz
spark-f89808b0fdbc04e1bdff1489a6ec4c84ddb2adc4.tar.bz2
spark-f89808b0fdbc04e1bdff1489a6ec4c84ddb2adc4.zip
[SPARK-17499][SPARKR][ML][MLLIB] make the default params in sparkR spark.mlp consistent with MultilayerPerceptronClassifier
## What changes were proposed in this pull request? update `MultilayerPerceptronClassifierWrapper.fit` paramter type: `layers: Array[Int]` `seed: String` update several default params in sparkR `spark.mlp`: `tol` --> 1e-6 `stepSize` --> 0.03 `seed` --> NULL ( when seed == NULL, the scala-side wrapper regard it as a `null` value and the seed will use the default one ) r-side `seed` only support 32bit integer. remove `layers` default value, and move it in front of those parameters with default value. add `layers` parameter validation check. ## How was this patch tested? tests added. Author: WeichenXu <WeichenXu123@outlook.com> Closes #15051 from WeichenXu123/update_py_mlp_default.
Diffstat (limited to 'mllib')
-rw-r--r--mllib/src/main/scala/org/apache/spark/ml/r/MultilayerPerceptronClassifierWrapper.scala8
1 files changed, 4 insertions, 4 deletions
diff --git a/mllib/src/main/scala/org/apache/spark/ml/r/MultilayerPerceptronClassifierWrapper.scala b/mllib/src/main/scala/org/apache/spark/ml/r/MultilayerPerceptronClassifierWrapper.scala
index be51e74187..1067300353 100644
--- a/mllib/src/main/scala/org/apache/spark/ml/r/MultilayerPerceptronClassifierWrapper.scala
+++ b/mllib/src/main/scala/org/apache/spark/ml/r/MultilayerPerceptronClassifierWrapper.scala
@@ -53,26 +53,26 @@ private[r] object MultilayerPerceptronClassifierWrapper
def fit(
data: DataFrame,
blockSize: Int,
- layers: Array[Double],
+ layers: Array[Int],
solver: String,
maxIter: Int,
tol: Double,
stepSize: Double,
- seed: Int
+ seed: String
): MultilayerPerceptronClassifierWrapper = {
// get labels and feature names from output schema
val schema = data.schema
// assemble and fit the pipeline
val mlp = new MultilayerPerceptronClassifier()
- .setLayers(layers.map(_.toInt))
+ .setLayers(layers)
.setBlockSize(blockSize)
.setSolver(solver)
.setMaxIter(maxIter)
.setTol(tol)
.setStepSize(stepSize)
- .setSeed(seed)
.setPredictionCol(PREDICTED_LABEL_COL)
+ if (seed != null && seed.length > 0) mlp.setSeed(seed.toInt)
val pipeline = new Pipeline()
.setStages(Array(mlp))
.fit(data)