You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by dongjoon-hyun <gi...@git.apache.org> on 2016/02/23 12:26:49 UTC

[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

GitHub user dongjoon-hyun opened a pull request:

    https://github.com/apache/spark/pull/11320

    [SPARK-11381][DOCS] Replace example code in mllib-linear-methods.md using include_example

    ## What changes were proposed in this pull request?
    
    This PR replaces example codes in `mllib-linear-methods.md` using `include_example`
    by doing the followings:
      * Extracts the example codes(Scala,Java,Python) as files in `example` module.
      * Merges some dialog-style examples into a single file.
      * Hide redundant codes in HTML for the consistency with other docs.
    
    ## How was the this patch tested?
    
    manual test.
    This PR can be tested by document generations, `SKIP_API=1 jekyll build`.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/dongjoon-hyun/spark SPARK-11381

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/11320.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #11320
    
----
commit 3093c70bf3d8f3807e470d61a3486f7effe82009
Author: Dongjoon Hyun <do...@apache.org>
Date:   2016-02-23T11:09:39Z

    [SPARK-11381][DOCS] Replace example code in mllib-linear-methods.md using include_example
    
    This PR replaces example codes in mllib-linear-methods.md using `include_example`
    by doing the followings:
      * Extracts the example codes(Scala,Java,Python) as files in `example` module.
      * Merges some dialog-style examples into a single file.
      * Hide redundant codes in HTML for the consistency with other docs.
    
    This PR can be tested by document generations, `SKIP_API=1 jekyll build`.

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-187930489
  
    **[Test build #51805 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/51805/consoleFull)** for PR 11320 at commit [`3e56717`](https://github.com/apache/spark/commit/3e5671703f4c978bfa00d3c88a453bf645c52915).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-187932341
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/51803/
    Test FAILed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by yinxusen <gi...@git.apache.org>.
Github user yinxusen commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-189160552
  
    @dongjoon-hyun No need to rush, you can wait until I finish the round of reviewing.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by dongjoon-hyun <gi...@git.apache.org>.
Github user dongjoon-hyun commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-187953829
  
    Test build 51808 is running now. Let's see the result. :)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-187999500
  
    Merged build finished. Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-187932335
  
    Merged build finished. Test FAILed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by yinxusen <gi...@git.apache.org>.
Github user yinxusen commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-188674650
  
    I'll do it tomorrow. Thx
    
    On Wed, Feb 24, 2016 at 3:12 PM, Dongjoon Hyun <no...@github.com>
    wrote:
    
    > Hi, @yinxusen <https://github.com/yinxusen> and @mengxr
    > <https://github.com/mengxr> .
    > Could you review this if you squeeze some time out of your schedule?
    >
    > —
    > Reply to this email directly or view it on GitHub
    > <https://github.com/apache/spark/pull/11320#issuecomment-188505409>.
    >
    
    
    
    -- 
    Cheers
    -----------------------------------
    Xusen Yin    (尹绪森)
    LinkedIn: https://cn.linkedin.com/in/xusenyin



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by dongjoon-hyun <gi...@git.apache.org>.
Github user dongjoon-hyun commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-189364055
  
    Thank you so much, @mengxr and @yinxusen !


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by dongjoon-hyun <gi...@git.apache.org>.
Github user dongjoon-hyun commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-188002229
  
    Finally! Now, it's ready to be reviewed again. :) 
    Thank you, all.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-189168035
  
    Merged build finished. Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by dongjoon-hyun <gi...@git.apache.org>.
Github user dongjoon-hyun commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-187821324
  
    Thank you for reviewing, @noprom . This PR is the similar to #11053  (merged yesterday.)
    
    Hi, @yinxusen, @mengxr .
    Could you review this PR? 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by yinxusen <gi...@git.apache.org>.
Github user yinxusen commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-189184055
  
    @dongjoon-hyun I finished the review. Thanks for working on this!


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by dongjoon-hyun <gi...@git.apache.org>.
Github user dongjoon-hyun commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-187959828
  
    According to Jenkins, other PRs also suffer from this. I think `retriggering` is not helpful at this time.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-187930931
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/51805/
    Test FAILed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by noprom <gi...@git.apache.org>.
Github user noprom commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-187667676
  
    So many changes in this commit.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by dongjoon-hyun <gi...@git.apache.org>.
Github user dongjoon-hyun commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-190632701
  
    Hi, @mengxr . 
    Could you close this PR? :)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by yinxusen <gi...@git.apache.org>.
Github user yinxusen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11320#discussion_r54218731
  
    --- Diff: docs/mllib-linear-methods.md ---
    @@ -748,49 +396,16 @@ online to the first stream, and make predictions on the second stream.
     
     First, we import the necessary classes for parsing our input data and creating the model.
     
    -{% highlight scala %}
    -
    -import org.apache.spark.mllib.linalg.Vectors
    -import org.apache.spark.mllib.regression.LabeledPoint
    -import org.apache.spark.mllib.regression.StreamingLinearRegressionWithSGD
    -
    -{% endhighlight %}
    -
     Then we make input streams for training and testing data. We assume a StreamingContext `ssc`
     has already been created, see [Spark Streaming Programming Guide](streaming-programming-guide.html#initializing)
     for more info. For this example, we use labeled points in training and testing streams,
     but in practice you will likely want to use unlabeled vectors for test data.
     
    -{% highlight scala %}
    -
    -val trainingData = ssc.textFileStream("/training/data/dir").map(LabeledPoint.parse).cache()
    -val testData = ssc.textFileStream("/testing/data/dir").map(LabeledPoint.parse)
    -
    -{% endhighlight %}
    -
    -We create our model by initializing the weights to 0
    -
    -{% highlight scala %}
    -
    -val numFeatures = 3
    -val model = new StreamingLinearRegressionWithSGD()
    -    .setInitialWeights(Vectors.zeros(numFeatures))
    -
    -{% endhighlight %}
    +We create our model by initializing the weights to 0.
     
     Now we register the streams for training and testing and start the job.
    --- End diff --
    
    delete the line


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by dongjoon-hyun <gi...@git.apache.org>.
Github user dongjoon-hyun commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-187924844
  
    Oh, thanks. I'll check the Jenkins in detail.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-189184620
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/52037/
    Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by yinxusen <gi...@git.apache.org>.
Github user yinxusen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11320#discussion_r54219036
  
    --- Diff: docs/mllib-linear-methods.md ---
    @@ -798,51 +413,24 @@ the model will update. Anytime a text file is placed in `/testing/data/dir` you
     As you feed more data to the training directory, the predictions
     will get better!
     
    +Here a complete example:
    --- End diff --
    
    Here is a complete example:


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/spark/pull/11320


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by yinxusen <gi...@git.apache.org>.
Github user yinxusen commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-189159634
  
    @dongjoon-hyun 
    
    Let's remove those examples:
    
    `L1UpdaterExample.scala`
    `JavaL1UpdaterExample.java`
    
    For these small pieces of codes, we can leave it untouched for now. Otherwise, there will be too many example codes.



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by dongjoon-hyun <gi...@git.apache.org>.
Github user dongjoon-hyun commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-189394636
  
    Hi, @mengxr . 
    Could you close this PR?
    It is merged to the master successfully, but is not closed until now. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by dongjoon-hyun <gi...@git.apache.org>.
Github user dongjoon-hyun commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-189161103
  
    Oh, I see. Then, let me know when you finish. :)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-187995996
  
    **[Test build #51825 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/51825/consoleFull)** for PR 11320 at commit [`12e40a0`](https://github.com/apache/spark/commit/12e40a0ffab54cdcf65c659a0b26f89c002682a5).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-189158854
  
    **[Test build #52037 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/52037/consoleFull)** for PR 11320 at commit [`92a3aff`](https://github.com/apache/spark/commit/92a3affbdd910548aaf79b00a9070afacf269f6d).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-187999504
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/51825/
    Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by yinxusen <gi...@git.apache.org>.
Github user yinxusen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11320#discussion_r54214094
  
    --- Diff: examples/src/main/java/org/apache/spark/examples/mllib/JavaL1UpdaterExample.java ---
    @@ -0,0 +1,84 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.examples.mllib;
    +
    +import scala.Tuple2;
    +
    +import org.apache.spark.api.java.*;
    +import org.apache.spark.api.java.function.Function;
    +import org.apache.spark.mllib.classification.*;
    +import org.apache.spark.mllib.evaluation.BinaryClassificationMetrics;
    +// $example on$
    +import org.apache.spark.mllib.optimization.L1Updater;
    +// $example off$
    +import org.apache.spark.mllib.regression.LabeledPoint;
    +import org.apache.spark.mllib.util.MLUtils;
    +import org.apache.spark.SparkConf;
    +import org.apache.spark.SparkContext;
    +
    +public class JavaL1UpdaterExample {
    +  public static void main(String[] args) {
    +    SparkConf conf = new SparkConf().setAppName("JavaL1UpdaterExample");
    +    SparkContext sc = new SparkContext(conf);
    +
    +    String path = "data/mllib/sample_libsvm_data.txt";
    +    JavaRDD<LabeledPoint> data = MLUtils.loadLibSVMFile(sc, path).toJavaRDD();
    +
    +    // Split initial RDD into two... [60% training data, 40% testing data].
    +    JavaRDD<LabeledPoint> training = data.sample(false, 0.6, 11L);
    +    training.cache();
    +    JavaRDD<LabeledPoint> test = data.subtract(training);
    +
    +    // Run training algorithm to build the model.
    +    int numIterations = 100;
    +    // $example on$
    +    SVMWithSGD svmAlg = new SVMWithSGD();
    +    svmAlg.optimizer()
    +            .setNumIterations(200)
    --- End diff --
    
    @dongjoon-hyun All Java files should follow 2-indent style.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by yinxusen <gi...@git.apache.org>.
Github user yinxusen commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-189209610
  
    @mengxr LGTM
    
    Note that we consolidate the original streaming linear regression example from small pieces into a complete example and modify some sentences.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by dongjoon-hyun <gi...@git.apache.org>.
Github user dongjoon-hyun commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-189160467
  
    Okay. No problem! I will update soon.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-189161423
  
    **[Test build #52040 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/52040/consoleFull)** for PR 11320 at commit [`239e09e`](https://github.com/apache/spark/commit/239e09e72a8a0ec36a33e4fdeedbac47bd63b9f3).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by dongjoon-hyun <gi...@git.apache.org>.
Github user dongjoon-hyun commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-190874901
  
    Thank you for closing this, @srowen and @mengxr . 



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-189194573
  
    **[Test build #52043 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/52043/consoleFull)** for PR 11320 at commit [`9000405`](https://github.com/apache/spark/commit/90004058248ed356252fddcfc86bdc913175b644).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by yinxusen <gi...@git.apache.org>.
Github user yinxusen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11320#discussion_r54218658
  
    --- Diff: docs/mllib-linear-methods.md ---
    @@ -748,49 +396,16 @@ online to the first stream, and make predictions on the second stream.
     
     First, we import the necessary classes for parsing our input data and creating the model.
     
    -{% highlight scala %}
    -
    -import org.apache.spark.mllib.linalg.Vectors
    -import org.apache.spark.mllib.regression.LabeledPoint
    -import org.apache.spark.mllib.regression.StreamingLinearRegressionWithSGD
    -
    -{% endhighlight %}
    -
     Then we make input streams for training and testing data. We assume a StreamingContext `ssc`
     has already been created, see [Spark Streaming Programming Guide](streaming-programming-guide.html#initializing)
     for more info. For this example, we use labeled points in training and testing streams,
     but in practice you will likely want to use unlabeled vectors for test data.
     
    -{% highlight scala %}
    -
    -val trainingData = ssc.textFileStream("/training/data/dir").map(LabeledPoint.parse).cache()
    -val testData = ssc.textFileStream("/testing/data/dir").map(LabeledPoint.parse)
    -
    -{% endhighlight %}
    -
    -We create our model by initializing the weights to 0
    -
    -{% highlight scala %}
    -
    -val numFeatures = 3
    -val model = new StreamingLinearRegressionWithSGD()
    -    .setInitialWeights(Vectors.zeros(numFeatures))
    -
    -{% endhighlight %}
    +We create our model by initializing the weights to 0.
    --- End diff --
    
    We create our model by initializing the weights to zero and register the streams for training and testing then start the job. Printing predictions alongside true labels lets us easily see the result.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by yinxusen <gi...@git.apache.org>.
Github user yinxusen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11320#discussion_r54218738
  
    --- Diff: docs/mllib-linear-methods.md ---
    @@ -748,49 +396,16 @@ online to the first stream, and make predictions on the second stream.
     
     First, we import the necessary classes for parsing our input data and creating the model.
     
    -{% highlight scala %}
    -
    -import org.apache.spark.mllib.linalg.Vectors
    -import org.apache.spark.mllib.regression.LabeledPoint
    -import org.apache.spark.mllib.regression.StreamingLinearRegressionWithSGD
    -
    -{% endhighlight %}
    -
     Then we make input streams for training and testing data. We assume a StreamingContext `ssc`
     has already been created, see [Spark Streaming Programming Guide](streaming-programming-guide.html#initializing)
     for more info. For this example, we use labeled points in training and testing streams,
     but in practice you will likely want to use unlabeled vectors for test data.
     
    -{% highlight scala %}
    -
    -val trainingData = ssc.textFileStream("/training/data/dir").map(LabeledPoint.parse).cache()
    -val testData = ssc.textFileStream("/testing/data/dir").map(LabeledPoint.parse)
    -
    -{% endhighlight %}
    -
    -We create our model by initializing the weights to 0
    -
    -{% highlight scala %}
    -
    -val numFeatures = 3
    -val model = new StreamingLinearRegressionWithSGD()
    -    .setInitialWeights(Vectors.zeros(numFeatures))
    -
    -{% endhighlight %}
    +We create our model by initializing the weights to 0.
     
     Now we register the streams for training and testing and start the job.
     Printing predictions alongside true labels lets us easily see the result.
    --- End diff --
    
    delete the line


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by yinxusen <gi...@git.apache.org>.
Github user yinxusen commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-189179012
  
    @dongjoon-hyun For the section of streaming linear regression: http://spark.apache.org/docs/latest/mllib-linear-methods.html#streaming-linear-regression, we should  change the following sentence:
    
    > Anytime a text file is placed in **/training/data/dir** the model will update. Anytime a text file is placed in **/testing/data/** dir you will see predictions. As you feed more data to the training directory, the predictions will get better!
    
    Substituting the bold words with `args(0)` and `args(1)` in Scala; `sys.argv[1]` and `sys.argv[2]` for Python.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by yinxusen <gi...@git.apache.org>.
Github user yinxusen commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-187940246
  
    @dongjoon-hyun You can use `dev/scalastyle`, `dev/lint-python`, etc. to simply the style check.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by dongjoon-hyun <gi...@git.apache.org>.
Github user dongjoon-hyun commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11320#discussion_r54215098
  
    --- Diff: examples/src/main/java/org/apache/spark/examples/mllib/JavaL1UpdaterExample.java ---
    @@ -0,0 +1,84 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.examples.mllib;
    +
    +import scala.Tuple2;
    +
    +import org.apache.spark.api.java.*;
    +import org.apache.spark.api.java.function.Function;
    +import org.apache.spark.mllib.classification.*;
    +import org.apache.spark.mllib.evaluation.BinaryClassificationMetrics;
    +// $example on$
    +import org.apache.spark.mllib.optimization.L1Updater;
    +// $example off$
    +import org.apache.spark.mllib.regression.LabeledPoint;
    +import org.apache.spark.mllib.util.MLUtils;
    +import org.apache.spark.SparkConf;
    +import org.apache.spark.SparkContext;
    +
    +public class JavaL1UpdaterExample {
    +  public static void main(String[] args) {
    +    SparkConf conf = new SparkConf().setAppName("JavaL1UpdaterExample");
    +    SparkContext sc = new SparkContext(conf);
    +
    +    String path = "data/mllib/sample_libsvm_data.txt";
    +    JavaRDD<LabeledPoint> data = MLUtils.loadLibSVMFile(sc, path).toJavaRDD();
    +
    +    // Split initial RDD into two... [60% training data, 40% testing data].
    +    JavaRDD<LabeledPoint> training = data.sample(false, 0.6, 11L);
    +    training.cache();
    +    JavaRDD<LabeledPoint> test = data.subtract(training);
    +
    +    // Run training algorithm to build the model.
    +    int numIterations = 100;
    +    // $example on$
    +    SVMWithSGD svmAlg = new SVMWithSGD();
    +    svmAlg.optimizer()
    +            .setNumIterations(200)
    --- End diff --
    
    @yinxusen . My bad. 
    I updated the PR to fix it.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by mengxr <gi...@git.apache.org>.
Github user mengxr commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-187898819
  
    cc @yinxusen 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-187908435
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/51793/
    Test FAILed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-187958355
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/51808/
    Test FAILed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by dongjoon-hyun <gi...@git.apache.org>.
Github user dongjoon-hyun commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-187940614
  
    Thank you so much, @yinxusen ! I'll fix soon and let you know here.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-189184298
  
    **[Test build #52037 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/52037/consoleFull)** for PR 11320 at commit [`92a3aff`](https://github.com/apache/spark/commit/92a3affbdd910548aaf79b00a9070afacf269f6d).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-189202798
  
    Merged build finished. Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by dongjoon-hyun <gi...@git.apache.org>.
Github user dongjoon-hyun commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-189195673
  
    I pushed the commit. 
    I've learn many things from you. Thank you very much, @yinxusen .


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by dongjoon-hyun <gi...@git.apache.org>.
Github user dongjoon-hyun commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-188505409
  
    Hi, @yinxusen and @mengxr .
    Could you review this if you squeeze some time out of your schedule?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by yinxusen <gi...@git.apache.org>.
Github user yinxusen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11320#discussion_r54218913
  
    --- Diff: docs/mllib-linear-methods.md ---
    @@ -748,49 +396,16 @@ online to the first stream, and make predictions on the second stream.
     
     First, we import the necessary classes for parsing our input data and creating the model.
     
    -{% highlight scala %}
    -
    -import org.apache.spark.mllib.linalg.Vectors
    -import org.apache.spark.mllib.regression.LabeledPoint
    -import org.apache.spark.mllib.regression.StreamingLinearRegressionWithSGD
    -
    -{% endhighlight %}
    -
     Then we make input streams for training and testing data. We assume a StreamingContext `ssc`
     has already been created, see [Spark Streaming Programming Guide](streaming-programming-guide.html#initializing)
     for more info. For this example, we use labeled points in training and testing streams,
     but in practice you will likely want to use unlabeled vectors for test data.
     
    -{% highlight scala %}
    -
    -val trainingData = ssc.textFileStream("/training/data/dir").map(LabeledPoint.parse).cache()
    -val testData = ssc.textFileStream("/testing/data/dir").map(LabeledPoint.parse)
    -
    -{% endhighlight %}
    -
    -We create our model by initializing the weights to 0
    -
    -{% highlight scala %}
    -
    -val numFeatures = 3
    -val model = new StreamingLinearRegressionWithSGD()
    -    .setInitialWeights(Vectors.zeros(numFeatures))
    -
    -{% endhighlight %}
    +We create our model by initializing the weights to 0.
     
     Now we register the streams for training and testing and start the job.
     Printing predictions alongside true labels lets us easily see the result.
     
    -{% highlight scala %}
    -
    -model.trainOn(trainingData)
    -model.predictOnValues(testData.map(lp => (lp.label, lp.features))).print()
    -
    -ssc.start()
    -ssc.awaitTermination()
    -
    -{% endhighlight %}
    -
     We can now save text files with data to the training or testing folders.
    --- End diff --
    
    Finally we can save text files with data to the training or testing folders.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-187930928
  
    Merged build finished. Test FAILed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-189202799
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/52043/
    Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-189167822
  
    **[Test build #52040 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/52040/consoleFull)** for PR 11320 at commit [`239e09e`](https://github.com/apache/spark/commit/239e09e72a8a0ec36a33e4fdeedbac47bd63b9f3).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by dongjoon-hyun <gi...@git.apache.org>.
Github user dongjoon-hyun commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11320#discussion_r54217273
  
    --- Diff: examples/src/main/python/mllib/svm_with_sgd_example.py ---
    @@ -0,0 +1,47 @@
    +#
    +# Licensed to the Apache Software Foundation (ASF) under one or more
    +# contributor license agreements.  See the NOTICE file distributed with
    +# this work for additional information regarding copyright ownership.
    +# The ASF licenses this file to You under the Apache License, Version 2.0
    +# (the "License"); you may not use this file except in compliance with
    +# the License.  You may obtain a copy of the License at
    +#
    +#    http://www.apache.org/licenses/LICENSE-2.0
    +#
    +# Unless required by applicable law or agreed to in writing, software
    +# distributed under the License is distributed on an "AS IS" BASIS,
    +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +# See the License for the specific language governing permissions and
    +# limitations under the License.
    +#
    +
    +# $example on$
    +from pyspark.mllib.classification import SVMWithSGD, SVMModel
    +from pyspark.mllib.regression import LabeledPoint
    +# $example off$
    +from pyspark import SparkContext
    --- End diff --
    
    But other python codes keep `from pyspark import SparkContext` outside, doesn't it?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-189160174
  
    **[Test build #52038 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/52038/consoleFull)** for PR 11320 at commit [`4d20391`](https://github.com/apache/spark/commit/4d20391c40920eaad304b027c5dd07ce18ab8609).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-189202550
  
    **[Test build #52043 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/52043/consoleFull)** for PR 11320 at commit [`9000405`](https://github.com/apache/spark/commit/90004058248ed356252fddcfc86bdc913175b644).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-189164979
  
    **[Test build #52038 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/52038/consoleFull)** for PR 11320 at commit [`4d20391`](https://github.com/apache/spark/commit/4d20391c40920eaad304b027c5dd07ce18ab8609).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-187958352
  
    Merged build finished. Test FAILed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by dongjoon-hyun <gi...@git.apache.org>.
Github user dongjoon-hyun commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-187958660
  
    Hmm, it fails again due to Github.
    ```
    ERROR: Timeout after 15 minutes
    ERROR: Error fetching remote repo 'origin'
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by mengxr <gi...@git.apache.org>.
Github user mengxr commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-189360050
  
    Merged into master. Thanks!


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-189184616
  
    Merged build finished. Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by dongjoon-hyun <gi...@git.apache.org>.
Github user dongjoon-hyun commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-189184319
  
    Thank you, @yinxusen ! 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by yinxusen <gi...@git.apache.org>.
Github user yinxusen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11320#discussion_r54218133
  
    --- Diff: examples/src/main/scala/org/apache/spark/examples/mllib/StreamingLinearRegressionExample.scala ---
    @@ -0,0 +1,58 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +// scalastyle:off println
    +package org.apache.spark.examples.mllib
    +
    +// $example on$
    +import org.apache.spark.mllib.linalg.Vectors
    +import org.apache.spark.mllib.regression.LabeledPoint
    +import org.apache.spark.mllib.regression.StreamingLinearRegressionWithSGD
    +// $example off$
    +import org.apache.spark.SparkConf
    +import org.apache.spark.streaming._
    +
    +object StreamingLinearRegressionExample {
    +
    +  def main(args: Array[String]): Unit = {
    +    if (args.length != 2) {
    +      System.err.println("Usage: StreamingLinearRegressionExample <trainingDir> <testDir>")
    +      System.exit(1)
    +    }
    +
    +    val conf = new SparkConf().setAppName("StreamingLinearRegressionExample")
    +    val ssc = new StreamingContext(conf, Seconds(1))
    +
    +    // $example on$
    +    val trainingData = ssc.textFileStream(args(0)).map(LabeledPoint.parse).cache()
    +    val testData = ssc.textFileStream(args(1)).map(LabeledPoint.parse)
    +
    +    val numFeatures = 3
    +    val model = new StreamingLinearRegressionWithSGD()
    +        .setInitialWeights(Vectors.zeros(numFeatures))
    --- End diff --
    
    2-idnent for scala code


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by dongjoon-hyun <gi...@git.apache.org>.
Github user dongjoon-hyun commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-187953113
  
    I've done!


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by dongjoon-hyun <gi...@git.apache.org>.
Github user dongjoon-hyun commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-187928402
  
    To be sure, I rebased this PR to the master, too.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by yinxusen <gi...@git.apache.org>.
Github user yinxusen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11320#discussion_r54216435
  
    --- Diff: examples/src/main/java/org/apache/spark/examples/mllib/JavaLogisticRegressionWithLBFGSExample.java ---
    @@ -0,0 +1,79 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.examples.mllib;
    +
    +// $example on$
    --- End diff --
    
    update the import block
    
    ```Java
    import org.apache.spark.SparkConf;
    import org.apache.spark.SparkContext;
    
    // $example on$
    import scala.Tuple2;
    
    import org.apache.spark.api.java.JavaRDD;
    import org.apache.spark.api.java.function.Function;
    import org.apache.spark.mllib.classification.LogisticRegressionModel;
    import org.apache.spark.mllib.classification.LogisticRegressionWithLBFGS;
    import org.apache.spark.mllib.evaluation.MulticlassMetrics;
    import org.apache.spark.mllib.regression.LabeledPoint;
    import org.apache.spark.mllib.util.MLUtils;
    // $example off$
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by dongjoon-hyun <gi...@git.apache.org>.
Github user dongjoon-hyun commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-187939511
  
    Let me fix the Scala style. I thought I passed since `build/mvn -DskipTests checkstyle:check` ends with 'SUCCESS'. Now, I see that there were printed '[ERROR]' lines. Sorry for missing that.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by yinxusen <gi...@git.apache.org>.
Github user yinxusen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11320#discussion_r54217011
  
    --- Diff: examples/src/main/python/mllib/svm_with_sgd_example.py ---
    @@ -0,0 +1,47 @@
    +#
    +# Licensed to the Apache Software Foundation (ASF) under one or more
    +# contributor license agreements.  See the NOTICE file distributed with
    +# this work for additional information regarding copyright ownership.
    +# The ASF licenses this file to You under the Apache License, Version 2.0
    +# (the "License"); you may not use this file except in compliance with
    +# the License.  You may obtain a copy of the License at
    +#
    +#    http://www.apache.org/licenses/LICENSE-2.0
    +#
    +# Unless required by applicable law or agreed to in writing, software
    +# distributed under the License is distributed on an "AS IS" BASIS,
    +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +# See the License for the specific language governing permissions and
    +# limitations under the License.
    +#
    +
    +# $example on$
    +from pyspark.mllib.classification import SVMWithSGD, SVMModel
    +from pyspark.mllib.regression import LabeledPoint
    +# $example off$
    +from pyspark import SparkContext
    --- End diff --
    
    This should be above of `# $example on$`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by yinxusen <gi...@git.apache.org>.
Github user yinxusen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11320#discussion_r54217909
  
    --- Diff: examples/src/main/scala/org/apache/spark/examples/mllib/StreamingLinearRegressionExample.scala ---
    @@ -0,0 +1,58 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +// scalastyle:off println
    +package org.apache.spark.examples.mllib
    +
    +// $example on$
    +import org.apache.spark.mllib.linalg.Vectors
    +import org.apache.spark.mllib.regression.LabeledPoint
    +import org.apache.spark.mllib.regression.StreamingLinearRegressionWithSGD
    +// $example off$
    +import org.apache.spark.SparkConf
    --- End diff --
    
    this line should above the `// $example on$`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by dongjoon-hyun <gi...@git.apache.org>.
Github user dongjoon-hyun commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-188902755
  
    Thank you, @yinxusen !


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-189165205
  
    Merged build finished. Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by yinxusen <gi...@git.apache.org>.
Github user yinxusen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11320#discussion_r54217241
  
    --- Diff: examples/src/main/scala/org/apache/spark/examples/mllib/LinearRegressionWithSGDExample.scala ---
    @@ -0,0 +1,64 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +// scalastyle:off println
    +package org.apache.spark.examples.mllib
    +
    +import org.apache.spark.{SparkConf, SparkContext}
    +// $example on$
    +import org.apache.spark.mllib.linalg.Vectors
    +import org.apache.spark.mllib.regression.LabeledPoint
    +import org.apache.spark.mllib.regression.LinearRegressionModel
    +import org.apache.spark.mllib.regression.LinearRegressionWithSGD
    +// $example off$
    +
    +object LinearRegressionWithSGDExample {
    +
    +  def main(args: Array[String]): Unit = {
    +    val conf = new SparkConf().setAppName("LinearRegressionWithSGDExample")
    +    val sc = new SparkContext(conf)
    +
    +    // $example on$
    +    // Load and parse the data
    +    val data = sc.textFile("data/mllib/ridge-data/lpsa.data")
    +    val parsedData = data.map { line =>
    +      val parts = line.split(',')
    +      LabeledPoint(parts(0).toDouble, Vectors.dense(parts(1).split(' ').map(_.toDouble)))
    +    }.cache()
    +
    +    // Building the model
    +    val numIterations = 100
    +    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 =>
    +      val prediction = model.predict(point.features)
    +      (point.label, prediction)
    +    }
    +    val MSE = valuesAndPreds.map{case(v, p) => math.pow((v - p), 2)}.mean()
    --- End diff --
    
    `val MSE = valuesAndPreds.map { case(v, p) => math.pow((v - p), 2) }.mean()`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-189165207
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/52038/
    Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by dongjoon-hyun <gi...@git.apache.org>.
Github user dongjoon-hyun commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11320#discussion_r54217329
  
    --- Diff: examples/src/main/python/mllib/svm_with_sgd_example.py ---
    @@ -0,0 +1,47 @@
    +#
    +# Licensed to the Apache Software Foundation (ASF) under one or more
    +# contributor license agreements.  See the NOTICE file distributed with
    +# this work for additional information regarding copyright ownership.
    +# The ASF licenses this file to You under the Apache License, Version 2.0
    +# (the "License"); you may not use this file except in compliance with
    +# the License.  You may obtain a copy of the License at
    +#
    +#    http://www.apache.org/licenses/LICENSE-2.0
    +#
    +# Unless required by applicable law or agreed to in writing, software
    +# distributed under the License is distributed on an "AS IS" BASIS,
    +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +# See the License for the specific language governing permissions and
    +# limitations under the License.
    +#
    +
    +# $example on$
    +from pyspark.mllib.classification import SVMWithSGD, SVMModel
    +from pyspark.mllib.regression import LabeledPoint
    +# $example off$
    +from pyspark import SparkContext
    --- End diff --
    
    Ah.. I see.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by dongjoon-hyun <gi...@git.apache.org>.
Github user dongjoon-hyun commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-187926696
  
    Actually, the error was Github timeout. I pushed force again. Could you ask Jenkins to retest please?
    ```
    +refs/pull/11320/*:refs/remotes/origin/pr/11320/* # timeout=15
    ERROR: Timeout after 15 minutes
    ERROR: Error fetching remote repo 'origin'
    hudson.plugins.git.GitException: Failed to fetch from https://github.com/apache/spark.git
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-187930921
  
    **[Test build #51805 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/51805/consoleFull)** for PR 11320 at commit [`3e56717`](https://github.com/apache/spark/commit/3e5671703f4c978bfa00d3c88a453bf645c52915).
     * This patch **fails Scala style tests**.
     * This patch merges cleanly.
     * This patch adds the following public classes _(experimental)_:
      * `public class JavaL1UpdaterExample `
      * `public class JavaLinearRegressionWithSGDExample `
      * `public class JavaLogisticRegressionWithLBFGSExample `
      * `public class JavaSVMWithSGDExample `


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-187660673
  
    Can one of the admins verify this patch?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-187908429
  
    Merged build finished. Test FAILed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-187999197
  
    **[Test build #51825 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/51825/consoleFull)** for PR 11320 at commit [`12e40a0`](https://github.com/apache/spark/commit/12e40a0ffab54cdcf65c659a0b26f89c002682a5).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds the following public classes _(experimental)_:
      * `public class JavaL1UpdaterExample `
      * `public class JavaLinearRegressionWithSGDExample `
      * `public class JavaLogisticRegressionWithLBFGSExample `
      * `public class JavaSVMWithSGDExample `


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by yinxusen <gi...@git.apache.org>.
Github user yinxusen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11320#discussion_r54215994
  
    --- Diff: examples/src/main/java/org/apache/spark/examples/mllib/JavaLinearRegressionWithSGDExample.java ---
    @@ -0,0 +1,93 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.examples.mllib;
    +
    +// $example on$
    --- End diff --
    
    Update the import block in this way:
    
    ```java
    import org.apache.spark.SparkConf;
    import org.apache.spark.api.java.JavaSparkContext;
    
    // $example on$
    import scala.Tuple2;
    
    import org.apache.spark.api.java.JavaDoubleRDD;
    import org.apache.spark.api.java.JavaRDD;
    import org.apache.spark.api.java.function.Function;
    import org.apache.spark.mllib.linalg.Vectors;
    import org.apache.spark.mllib.regression.LabeledPoint;
    import org.apache.spark.mllib.regression.LinearRegressionModel;
    import org.apache.spark.mllib.regression.LinearRegressionWithSGD;
    // $example off$
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by yinxusen <gi...@git.apache.org>.
Github user yinxusen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11320#discussion_r54216625
  
    --- Diff: examples/src/main/java/org/apache/spark/examples/mllib/JavaSVMWithSGDExample.java ---
    @@ -0,0 +1,80 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.examples.mllib;
    +
    +// $example on$
    --- End diff --
    
    import like this:
    
    ```java
    import org.apache.spark.SparkConf;
    import org.apache.spark.SparkContext;
    
    // $example on$
    import scala.Tuple2;
    
    import org.apache.spark.api.java.JavaRDD;
    import org.apache.spark.api.java.function.Function;
    import org.apache.spark.mllib.classification.SVMModel;
    import org.apache.spark.mllib.classification.SVMWithSGD;
    import org.apache.spark.mllib.evaluation.BinaryClassificationMetrics;
    import org.apache.spark.mllib.regression.LabeledPoint;
    import org.apache.spark.mllib.util.MLUtils;
    // $example off$
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by yinxusen <gi...@git.apache.org>.
Github user yinxusen commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-187960277
  
    We can wait for a while. No worry.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by srowen <gi...@git.apache.org>.
Github user srowen commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-190671006
  
    @dongjoon-hyun normally the Apache ASF bot closes the PRs automatically, but I don't know why this one was not closed. We actually can't close PRs. You would have to close it manually.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by yinxusen <gi...@git.apache.org>.
Github user yinxusen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11320#discussion_r54219689
  
    --- Diff: examples/src/main/python/mllib/streaming_linear_regression_example.py ---
    @@ -0,0 +1,60 @@
    +#
    +# Licensed to the Apache Software Foundation (ASF) under one or more
    +# contributor license agreements.  See the NOTICE file distributed with
    +# this work for additional information regarding copyright ownership.
    +# The ASF licenses this file to You under the Apache License, Version 2.0
    +# (the "License"); you may not use this file except in compliance with
    +# the License.  You may obtain a copy of the License at
    +#
    +#    http://www.apache.org/licenses/LICENSE-2.0
    +#
    +# Unless required by applicable law or agreed to in writing, software
    +# distributed under the License is distributed on an "AS IS" BASIS,
    +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +# See the License for the specific language governing permissions and
    +# limitations under the License.
    +#
    +
    +"""
    +Streaming Linear Regression Example.
    +"""
    +from __future__ import print_function
    +
    +import sys
    --- End diff --
    
    change the line to:
    
    ```python
    # $example on$
    import sys
    # $example off$
    
    Since the truncated code uses the sys.argv[1].


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-189168039
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/52040/
    Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by yinxusen <gi...@git.apache.org>.
Github user yinxusen commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-189183577
  
    @dongjoon-hyun One more thing, try to make the output dirs different for different examples. Like there are 3 examples (Scala/Java/Python versions) use `target/tmp/myLinearRegressionWithSGDModel`. We cannot run those examples once a time if we don't delete the dir generated before.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by yinxusen <gi...@git.apache.org>.
Github user yinxusen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11320#discussion_r54216178
  
    --- Diff: examples/src/main/java/org/apache/spark/examples/mllib/JavaLinearRegressionWithSGDExample.java ---
    @@ -0,0 +1,93 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.examples.mllib;
    +
    +// $example on$
    +import scala.Tuple2;
    +
    +import org.apache.spark.api.java.*;
    +import org.apache.spark.api.java.function.Function;
    +import org.apache.spark.mllib.linalg.Vector;
    +import org.apache.spark.mllib.linalg.Vectors;
    +import org.apache.spark.mllib.regression.LabeledPoint;
    +import org.apache.spark.mllib.regression.LinearRegressionModel;
    +import org.apache.spark.mllib.regression.LinearRegressionWithSGD;
    +// $example off$
    +
    +import org.apache.spark.SparkConf;
    +import org.apache.spark.SparkContext;
    +
    +/**
    + * Example for LinearRegressionWithSGD.
    + */
    +public class JavaLinearRegressionWithSGDExample {
    +  public static void main(String[] args) {
    +    SparkConf conf = new SparkConf().setAppName("JavaLinearRegressionWithSGDExample");
    +    JavaSparkContext sc = new JavaSparkContext(conf);
    +
    +    // $example on$
    +    // Load and parse the data
    +    String path = "data/mllib/ridge-data/lpsa.data";
    +    JavaRDD<String> data = sc.textFile(path);
    +    JavaRDD<LabeledPoint> parsedData = data.map(
    +      new Function<String, LabeledPoint>() {
    +        public LabeledPoint call(String line) {
    +          String[] parts = line.split(",");
    +          String[] features = parts[1].split(" ");
    +          double[] v = new double[features.length];
    +          for (int i = 0; i < features.length - 1; i++) {
    +            v[i] = Double.parseDouble(features[i]);
    +          }
    +          return new LabeledPoint(Double.parseDouble(parts[0]), Vectors.dense(v));
    +        }
    +      }
    +    );
    +    parsedData.cache();
    +
    +    // Building the model
    +    int numIterations = 100;
    +    double stepSize = 0.00000001;
    +    final LinearRegressionModel model =
    +      LinearRegressionWithSGD.train(JavaRDD.toRDD(parsedData), numIterations, stepSize);
    +
    +    // Evaluate model on training examples and compute training error
    +    JavaRDD<Tuple2<Double, Double>> valuesAndPreds = parsedData.map(
    +      new Function<LabeledPoint, Tuple2<Double, Double>>() {
    +        public Tuple2<Double, Double> call(LabeledPoint point) {
    +          double prediction = model.predict(point.features());
    +          return new Tuple2<Double, Double>(prediction, point.label());
    +        }
    +      }
    +    );
    +    double MSE = new JavaDoubleRDD(valuesAndPreds.map(
    +      new Function<Tuple2<Double, Double>, Object>() {
    +        public Object call(Tuple2<Double, Double> pair) {
    +          return Math.pow(pair._1() - pair._2(), 2.0);
    +        }
    +      }
    +    ).rdd()).mean();
    +    System.out.println("training Mean Squared Error = " + MSE);
    +
    +    // Save and load model
    +    model.save(sc.sc(), "target/tmp/myLinearRegressionWithSGDModel");
    +    LinearRegressionModel sameModel = LinearRegressionModel.load(sc.sc(), "target/tmp/myLinearRegressionWithSGDModel");
    --- End diff --
    
    exceed 100 chars limitation.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by yinxusen <gi...@git.apache.org>.
Github user yinxusen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11320#discussion_r54217696
  
    --- Diff: examples/src/main/scala/org/apache/spark/examples/mllib/LogisticRegressionWithLBFGSExample.scala ---
    @@ -0,0 +1,70 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +// scalastyle:off println
    +package org.apache.spark.examples.mllib
    +
    +import org.apache.spark.{SparkConf, SparkContext}
    +// $example on$
    +import org.apache.spark.mllib.classification.{LogisticRegressionModel, LogisticRegressionWithLBFGS}
    +import org.apache.spark.mllib.evaluation.MulticlassMetrics
    +import org.apache.spark.mllib.linalg.Vectors
    --- End diff --
    
    remove it


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-11381][DOCS] Replace example code in ml...

Posted by mengxr <gi...@git.apache.org>.
Github user mengxr commented on the pull request:

    https://github.com/apache/spark/pull/11320#issuecomment-187898787
  
    ok to test


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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