diff --git a/examples/src/main/scala/org/apache/spark/examples/ml/LinearRegressionExample.scala b/examples/src/main/scala/org/apache/spark/examples/ml/LinearRegressionExample.scala index b5377b1ca0f78..b54466fd48bc5 100644 --- a/examples/src/main/scala/org/apache/spark/examples/ml/LinearRegressionExample.scala +++ b/examples/src/main/scala/org/apache/spark/examples/ml/LinearRegressionExample.scala @@ -68,7 +68,7 @@ object LinearRegressionExample { s"L1 and L2, default: ${defaultParams.elasticNetParam}") .action((x, c) => c.copy(elasticNetParam = x)) opt[Int]("maxIter") - .text(s"maximal number of iterations, default: ${defaultParams.maxIter}") + .text(s"maximum number of iterations, default: ${defaultParams.maxIter}") .action((x, c) => c.copy(maxIter = x)) opt[Double]("tol") .text(s"the convergence tolerance of iterations, Smaller value will lead " + @@ -115,9 +115,6 @@ object LinearRegressionExample { val (training: DataFrame, test: DataFrame) = DecisionTreeExample.loadDatasets(sc, params.input, params.dataFormat, params.testInput, "regression", params.fracTest) - // Set up Pipeline - val stages = new mutable.ArrayBuffer[PipelineStage]() - val lir = new LinearRegression() .setFeaturesCol("features") .setLabelCol("label") @@ -126,23 +123,19 @@ object LinearRegressionExample { .setMaxIter(params.maxIter) .setTol(params.tol) - stages += lir - val pipeline = new Pipeline().setStages(stages.toArray) - - // Fit the Pipeline + // Train the model val startTime = System.nanoTime() - val pipelineModel = pipeline.fit(training) + val lirModel = lir.fit(training) val elapsedTime = (System.nanoTime() - startTime) / 1e9 println(s"Training time: $elapsedTime seconds") - val lirModel = pipelineModel.stages.last.asInstanceOf[LinearRegressionModel] // Print the weights and intercept for linear regression. println(s"Weights: ${lirModel.weights} Intercept: ${lirModel.intercept}") println("Training data results:") - DecisionTreeExample.evaluateRegressionModel(pipelineModel, training, "label") + DecisionTreeExample.evaluateRegressionModel(lirModel, training, "label") println("Test data results:") - DecisionTreeExample.evaluateRegressionModel(pipelineModel, test, "label") + DecisionTreeExample.evaluateRegressionModel(lirModel, test, "label") sc.stop() } diff --git a/examples/src/main/scala/org/apache/spark/examples/ml/LogisticRegressionExample.scala b/examples/src/main/scala/org/apache/spark/examples/ml/LogisticRegressionExample.scala index b7620db974f7a..8559930493bfd 100644 --- a/examples/src/main/scala/org/apache/spark/examples/ml/LogisticRegressionExample.scala +++ b/examples/src/main/scala/org/apache/spark/examples/ml/LogisticRegressionExample.scala @@ -70,7 +70,7 @@ object LogisticRegressionExample { s"L1 and L2, default: ${defaultParams.elasticNetParam}") .action((x, c) => c.copy(elasticNetParam = x)) opt[Int]("maxIter") - .text(s"maximal number of iterations, default: ${defaultParams.maxIter}") + .text(s"maximum number of iterations, default: ${defaultParams.maxIter}") .action((x, c) => c.copy(maxIter = x)) opt[Boolean]("fitIntercept") .text(s"whether to fit an intercept term, default: ${defaultParams.fitIntercept}") diff --git a/mllib/src/main/scala/org/apache/spark/ml/classification/LogisticRegression.scala b/mllib/src/main/scala/org/apache/spark/ml/classification/LogisticRegression.scala index d13109d9da4c0..f136bcee9cf2b 100644 --- a/mllib/src/main/scala/org/apache/spark/ml/classification/LogisticRegression.scala +++ b/mllib/src/main/scala/org/apache/spark/ml/classification/LogisticRegression.scala @@ -74,7 +74,7 @@ class LogisticRegression(override val uid: String) setDefault(elasticNetParam -> 0.0) /** - * Set the maximal number of iterations. + * Set the maximum number of iterations. * Default is 100. * @group setParam */ @@ -90,7 +90,11 @@ class LogisticRegression(override val uid: String) def setTol(value: Double): this.type = set(tol, value) setDefault(tol -> 1E-6) - /** @group setParam */ + /** + * Whether to fit an intercept term. + * Default is true. + * @group setParam + * */ def setFitIntercept(value: Boolean): this.type = set(fitIntercept, value) setDefault(fitIntercept -> true) diff --git a/mllib/src/main/scala/org/apache/spark/ml/param/shared/SharedParamsCodeGen.scala b/mllib/src/main/scala/org/apache/spark/ml/param/shared/SharedParamsCodeGen.scala index 1ffb5eddc36bd..8ffbcf0d8bc71 100644 --- a/mllib/src/main/scala/org/apache/spark/ml/param/shared/SharedParamsCodeGen.scala +++ b/mllib/src/main/scala/org/apache/spark/ml/param/shared/SharedParamsCodeGen.scala @@ -33,7 +33,7 @@ private[shared] object SharedParamsCodeGen { val params = Seq( ParamDesc[Double]("regParam", "regularization parameter (>= 0)", isValid = "ParamValidators.gtEq(0)"), - ParamDesc[Int]("maxIter", "max number of iterations (>= 0)", + ParamDesc[Int]("maxIter", "maximum number of iterations (>= 0)", isValid = "ParamValidators.gtEq(0)"), ParamDesc[String]("featuresCol", "features column name", Some("\"features\"")), ParamDesc[String]("labelCol", "label column name", Some("\"label\"")), diff --git a/mllib/src/main/scala/org/apache/spark/ml/param/shared/sharedParams.scala b/mllib/src/main/scala/org/apache/spark/ml/param/shared/sharedParams.scala index ed08417bd4df8..a0c8ccdac9ad9 100644 --- a/mllib/src/main/scala/org/apache/spark/ml/param/shared/sharedParams.scala +++ b/mllib/src/main/scala/org/apache/spark/ml/param/shared/sharedParams.scala @@ -45,10 +45,10 @@ private[ml] trait HasRegParam extends Params { private[ml] trait HasMaxIter extends Params { /** - * Param for max number of iterations (>= 0). + * Param for maximum number of iterations (>= 0). * @group param */ - final val maxIter: IntParam = new IntParam(this, "maxIter", "max number of iterations (>= 0)", ParamValidators.gtEq(0)) + final val maxIter: IntParam = new IntParam(this, "maxIter", "maximum number of iterations (>= 0)", ParamValidators.gtEq(0)) /** @group getParam */ final def getMaxIter: Int = $(maxIter) diff --git a/mllib/src/main/scala/org/apache/spark/ml/regression/LinearRegression.scala b/mllib/src/main/scala/org/apache/spark/ml/regression/LinearRegression.scala index fe2a71a331694..70cd8e9e87fae 100644 --- a/mllib/src/main/scala/org/apache/spark/ml/regression/LinearRegression.scala +++ b/mllib/src/main/scala/org/apache/spark/ml/regression/LinearRegression.scala @@ -83,7 +83,7 @@ class LinearRegression(override val uid: String) setDefault(elasticNetParam -> 0.0) /** - * Set the maximal number of iterations. + * Set the maximum number of iterations. * Default is 100. * @group setParam */