aboutsummaryrefslogtreecommitdiff
path: root/docs/mllib-isotonic-regression.md
diff options
context:
space:
mode:
authorYuhao Yang <hhbyyh@gmail.com>2015-05-31 11:51:49 -0700
committerJoseph K. Bradley <joseph@databricks.com>2015-05-31 11:51:49 -0700
commit0674700303da3e4737d73f5fabd2a925ec712f63 (patch)
treeaccc878afed083e7603a6ff11ad7f5be71e45555 /docs/mllib-isotonic-regression.md
parente1067d0ad1c32c678c23d76d7653b51770795831 (diff)
downloadspark-0674700303da3e4737d73f5fabd2a925ec712f63.tar.gz
spark-0674700303da3e4737d73f5fabd2a925ec712f63.tar.bz2
spark-0674700303da3e4737d73f5fabd2a925ec712f63.zip
[SPARK-7949] [MLLIB] [DOC] update document with some missing save/load
add save load for examples: KMeansModel PowerIterationClusteringModel Word2VecModel IsotonicRegressionModel Author: Yuhao Yang <hhbyyh@gmail.com> Closes #6498 from hhbyyh/docSaveLoad and squashes the following commits: 7f9f06d [Yuhao Yang] add missing imports c604cad [Yuhao Yang] Merge remote-tracking branch 'upstream/master' into docSaveLoad 1dd77cc [Yuhao Yang] update document with some missing save/load
Diffstat (limited to 'docs/mllib-isotonic-regression.md')
-rw-r--r--docs/mllib-isotonic-regression.md10
1 files changed, 9 insertions, 1 deletions
diff --git a/docs/mllib-isotonic-regression.md b/docs/mllib-isotonic-regression.md
index b521c2f27c..5732bc4c7e 100644
--- a/docs/mllib-isotonic-regression.md
+++ b/docs/mllib-isotonic-regression.md
@@ -60,7 +60,7 @@ Model is created using the training set and a mean squared error is calculated f
labels and real labels in the test set.
{% highlight scala %}
-import org.apache.spark.mllib.regression.IsotonicRegression
+import org.apache.spark.mllib.regression.{IsotonicRegression, IsotonicRegressionModel}
val data = sc.textFile("data/mllib/sample_isotonic_regression_data.txt")
@@ -88,6 +88,10 @@ val predictionAndLabel = test.map { point =>
// Calculate mean squared error between predicted and real labels.
val meanSquaredError = predictionAndLabel.map{case(p, l) => math.pow((p - l), 2)}.mean()
println("Mean Squared Error = " + meanSquaredError)
+
+// Save and load model
+model.save(sc, "myModelPath")
+val sameModel = IsotonicRegressionModel.load(sc, "myModelPath")
{% endhighlight %}
</div>
@@ -150,6 +154,10 @@ Double meanSquaredError = new JavaDoubleRDD(predictionAndLabel.map(
).rdd()).mean();
System.out.println("Mean Squared Error = " + meanSquaredError);
+
+// Save and load model
+model.save(sc.sc(), "myModelPath");
+IsotonicRegressionModel sameModel = IsotonicRegressionModel.load(sc.sc(), "myModelPath");
{% endhighlight %}
</div>
</div>