diff options
author | Yuhao Yang <hhbyyh@gmail.com> | 2015-07-01 11:17:56 -0700 |
---|---|---|
committer | Joseph K. Bradley <joseph@databricks.com> | 2015-07-01 11:17:56 -0700 |
commit | 2012913355993e6516e4c81dbc92e579977131da (patch) | |
tree | ebb302ea581314397e679ba5d8733465d5f03272 /docs/mllib-naive-bayes.md | |
parent | 184de91d15a4bfc5c014e8cf86211874bba4593f (diff) | |
download | spark-2012913355993e6516e4c81dbc92e579977131da.tar.gz spark-2012913355993e6516e4c81dbc92e579977131da.tar.bz2 spark-2012913355993e6516e4c81dbc92e579977131da.zip |
[SPARK-8308] [MLLIB] add missing save load for python example
jira: https://issues.apache.org/jira/browse/SPARK-8308
1. add some missing save/load in python examples. , LogisticRegression, LinearRegression and NaiveBayes
2. tune down iterations for MatrixFactorization, since current number will trigger StackOverflow for default java configuration (>1M)
Author: Yuhao Yang <hhbyyh@gmail.com>
Closes #6760 from hhbyyh/docUpdate and squashes the following commits:
9bd3383 [Yuhao Yang] update scala example
8a44692 [Yuhao Yang] Merge remote-tracking branch 'upstream/master' into docUpdate
077cbb8 [Yuhao Yang] Merge remote-tracking branch 'upstream/master' into docUpdate
3e948dc [Yuhao Yang] add missing save load for python example
Diffstat (limited to 'docs/mllib-naive-bayes.md')
-rw-r--r-- | docs/mllib-naive-bayes.md | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/docs/mllib-naive-bayes.md b/docs/mllib-naive-bayes.md index bf6d124fd5..e73bd30f3a 100644 --- a/docs/mllib-naive-bayes.md +++ b/docs/mllib-naive-bayes.md @@ -119,7 +119,7 @@ used for evaluation and prediction. Note that the Python API does not yet support model save/load but will in the future. {% highlight python %} -from pyspark.mllib.classification import NaiveBayes +from pyspark.mllib.classification import NaiveBayes, NaiveBayesModel from pyspark.mllib.linalg import Vectors from pyspark.mllib.regression import LabeledPoint @@ -140,6 +140,10 @@ model = NaiveBayes.train(training, 1.0) # Make prediction and test accuracy. predictionAndLabel = test.map(lambda p : (model.predict(p.features), p.label)) accuracy = 1.0 * predictionAndLabel.filter(lambda (x, v): x == v).count() / test.count() + +# Save and load model +model.save(sc, "myModelPath") +sameModel = NaiveBayesModel.load(sc, "myModelPath") {% endhighlight %} </div> |