You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by sr...@apache.org on 2016/01/12 13:13:36 UTC
spark git commit: [SPARK-5273][MLLIB][DOCS] Improve documentation
examples for LinearRegression
Repository: spark
Updated Branches:
refs/heads/master c48f2a3a5 -> 9c7f34af3
[SPARK-5273][MLLIB][DOCS] Improve documentation examples for LinearRegression
Use a much smaller step size in LinearRegressionWithSGD MLlib examples to achieve a reasonable RMSE.
Our training folks hit this exact same issue when concocting an example and had the same solution.
Author: Sean Owen <so...@cloudera.com>
Closes #10675 from srowen/SPARK-5273.
Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/9c7f34af
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/9c7f34af
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/9c7f34af
Branch: refs/heads/master
Commit: 9c7f34af37ef328149c1d66b4689d80a1589e1cc
Parents: c48f2a3
Author: Sean Owen <so...@cloudera.com>
Authored: Tue Jan 12 12:13:32 2016 +0000
Committer: Sean Owen <so...@cloudera.com>
Committed: Tue Jan 12 12:13:32 2016 +0000
----------------------------------------------------------------------
docs/mllib-linear-methods.md | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/spark/blob/9c7f34af/docs/mllib-linear-methods.md
----------------------------------------------------------------------
diff --git a/docs/mllib-linear-methods.md b/docs/mllib-linear-methods.md
index 20b3561..aac8f75 100644
--- a/docs/mllib-linear-methods.md
+++ b/docs/mllib-linear-methods.md
@@ -590,7 +590,8 @@ val parsedData = data.map { line =>
// Building the model
val numIterations = 100
-val model = LinearRegressionWithSGD.train(parsedData, numIterations)
+val stepSize = 0.00000001
+val model = LinearRegressionWithSGD.train(parsedData, numIterations, stepSize)
// Evaluate model on training examples and compute training error
val valuesAndPreds = parsedData.map { point =>
@@ -655,8 +656,9 @@ public class LinearRegression {
// Building the model
int numIterations = 100;
+ double stepSize = 0.00000001;
final LinearRegressionModel model =
- LinearRegressionWithSGD.train(JavaRDD.toRDD(parsedData), numIterations);
+ LinearRegressionWithSGD.train(JavaRDD.toRDD(parsedData), numIterations, stepSize);
// Evaluate model on training examples and compute training error
JavaRDD<Tuple2<Double, Double>> valuesAndPreds = parsedData.map(
@@ -706,7 +708,7 @@ data = sc.textFile("data/mllib/ridge-data/lpsa.data")
parsedData = data.map(parsePoint)
# Build the model
-model = LinearRegressionWithSGD.train(parsedData)
+model = LinearRegressionWithSGD.train(parsedData, iterations=100, step=0.00000001)
# Evaluate the model on training data
valuesAndPreds = parsedData.map(lambda p: (p.label, model.predict(p.features)))
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org