You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by me...@apache.org on 2016/02/24 00:57:32 UTC

spark git commit: [SPARK-10759][ML] update cross validator with include_example

Repository: spark
Updated Branches:
  refs/heads/master 8d29001de -> 230bbeaa6


[SPARK-10759][ML] update cross validator with include_example

This pull request uses {%include_example%} to add an example for the python cross validator to ml-guide.

Author: JeremyNixon <jn...@gmail.com>

Closes #11240 from JeremyNixon/pipeline_include_example.


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/230bbeaa
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/230bbeaa
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/230bbeaa

Branch: refs/heads/master
Commit: 230bbeaa614ed0ee87ecceece42355dd9a4bacb3
Parents: 8d29001
Author: JeremyNixon <jn...@gmail.com>
Authored: Tue Feb 23 15:57:29 2016 -0800
Committer: Xiangrui Meng <me...@databricks.com>
Committed: Tue Feb 23 15:57:29 2016 -0800

----------------------------------------------------------------------
 docs/ml-guide.md                               | 5 +++++
 examples/src/main/python/ml/cross_validator.py | 5 ++++-
 2 files changed, 9 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/230bbeaa/docs/ml-guide.md
----------------------------------------------------------------------
diff --git a/docs/ml-guide.md b/docs/ml-guide.md
index 5900d66..a5a825f6 100644
--- a/docs/ml-guide.md
+++ b/docs/ml-guide.md
@@ -283,6 +283,11 @@ However, it is also a well-established method for choosing parameters which is m
 {% include_example java/org/apache/spark/examples/ml/JavaModelSelectionViaCrossValidationExample.java %}
 </div>
 
+<div data-lang="python">
+
+{% include_example python/ml/cross_validator.py %}
+</div>
+
 </div>
 
 ## Example: model selection via train validation split

http://git-wip-us.apache.org/repos/asf/spark/blob/230bbeaa/examples/src/main/python/ml/cross_validator.py
----------------------------------------------------------------------
diff --git a/examples/src/main/python/ml/cross_validator.py b/examples/src/main/python/ml/cross_validator.py
index f0ca97c..5f0ef20 100644
--- a/examples/src/main/python/ml/cross_validator.py
+++ b/examples/src/main/python/ml/cross_validator.py
@@ -18,12 +18,14 @@
 from __future__ import print_function
 
 from pyspark import SparkContext
+# $example on$
 from pyspark.ml import Pipeline
 from pyspark.ml.classification import LogisticRegression
 from pyspark.ml.evaluation import BinaryClassificationEvaluator
 from pyspark.ml.feature import HashingTF, Tokenizer
 from pyspark.ml.tuning import CrossValidator, ParamGridBuilder
 from pyspark.sql import Row, SQLContext
+# $example off$
 
 """
 A simple example demonstrating model selection using CrossValidator.
@@ -36,7 +38,7 @@ Run with:
 if __name__ == "__main__":
     sc = SparkContext(appName="CrossValidatorExample")
     sqlContext = SQLContext(sc)
-
+    # $example on$
     # Prepare training documents, which are labeled.
     LabeledDocument = Row("id", "text", "label")
     training = sc.parallelize([(0, "a b c d e spark", 1.0),
@@ -92,5 +94,6 @@ if __name__ == "__main__":
     selected = prediction.select("id", "text", "probability", "prediction")
     for row in selected.collect():
         print(row)
+    # $example off$
 
     sc.stop()


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org