You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by mengxr <gi...@git.apache.org> on 2015/02/06 19:18:25 UTC

[GitHub] spark pull request: [SPARK-5601][MLLIB] make streaming linear algo...

GitHub user mengxr opened a pull request:

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

    [SPARK-5601][MLLIB] make streaming linear algorithms Java-friendly

    Overload `trainOn`, `predictOn`, and `predictOnValues`.
    
    CC @freeman-lab

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

    $ git pull https://github.com/mengxr/spark streaming-java

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

    https://github.com/apache/spark/pull/4432.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 #4432
    
----
commit 1f662b376a87f2f226759a5e97f8b9afe27c55d7
Author: Xiangrui Meng <me...@databricks.com>
Date:   2015-02-06T18:15:59Z

    make streaming linear algorithms Java-friendly

----


---
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-5601][MLLIB] make streaming linear algo...

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

    https://github.com/apache/spark/pull/4432#issuecomment-73334007
  
    Merged into master and branch-1.3.


---
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-5601][MLLIB] make streaming linear algo...

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

    https://github.com/apache/spark/pull/4432#discussion_r24276437
  
    --- Diff: mllib/src/test/java/org/apache/spark/mllib/regression/JavaStreamingLinearRegressionSuite.java ---
    @@ -0,0 +1,80 @@
    +/*
    --- End diff --
    
    Sure.


---
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-5601][MLLIB] make streaming linear algo...

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

    https://github.com/apache/spark/pull/4432#issuecomment-73332854
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/26955/
    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-5601][MLLIB] make streaming linear algo...

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

    https://github.com/apache/spark/pull/4432#issuecomment-73286642
  
      [Test build #26922 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/26922/consoleFull) for   PR 4432 at commit [`1f662b3`](https://github.com/apache/spark/commit/1f662b376a87f2f226759a5e97f8b9afe27c55d7).
     * This patch merges cleanly.


---
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-5601][MLLIB] make streaming linear algo...

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

    https://github.com/apache/spark/pull/4432#issuecomment-73305358
  
    Looks good, but not too familiar with this class


---
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-5601][MLLIB] make streaming linear algo...

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

    https://github.com/apache/spark/pull/4432#issuecomment-73325737
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/26943/
    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-5601][MLLIB] make streaming linear algo...

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

    https://github.com/apache/spark/pull/4432#issuecomment-73317241
  
    @mengxr nice patch! I left two pretty minor comments about expanding the tests, otherwise looking good.


---
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-5601][MLLIB] make streaming linear algo...

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

    https://github.com/apache/spark/pull/4432#discussion_r24273893
  
    --- Diff: mllib/src/test/java/org/apache/spark/mllib/regression/JavaStreamingLinearRegressionSuite.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.mllib.regression;
    +
    +import java.io.Serializable;
    +import java.util.List;
    +
    +import scala.Tuple2;
    +
    +import com.google.common.collect.Lists;
    +import org.junit.After;
    +import org.junit.Before;
    +import org.junit.Test;
    +
    +import org.apache.spark.SparkConf;
    +import org.apache.spark.mllib.linalg.Vector;
    +import org.apache.spark.mllib.linalg.Vectors;
    +import org.apache.spark.streaming.Duration;
    +import org.apache.spark.streaming.api.java.JavaDStream;
    +import org.apache.spark.streaming.api.java.JavaPairDStream;
    +import org.apache.spark.streaming.api.java.JavaStreamingContext;
    +import static org.apache.spark.streaming.JavaTestUtils.*;
    +
    +public class JavaStreamingLinearRegressionSuite implements Serializable {
    +
    +  protected transient JavaStreamingContext ssc;
    +
    +  @Before
    +  public void setUp() {
    +    SparkConf conf = new SparkConf()
    +      .setMaster("local[2]")
    +      .setAppName("test")
    +      .set("spark.streaming.clock", "org.apache.spark.streaming.util.ManualClock");
    +    ssc = new JavaStreamingContext(conf, new Duration(1000));
    +    ssc.checkpoint("checkpoint");
    +  }
    +
    +  @After
    +  public void tearDown() {
    +    ssc.stop();
    +    ssc = null;
    +  }
    +
    +  @Test
    +  @SuppressWarnings("unchecked")
    +  public void javaAPI() {
    +    List<LabeledPoint> trainingBatch = Lists.newArrayList(
    +      new LabeledPoint(1.0, Vectors.dense(1.0)),
    +      new LabeledPoint(0.0, Vectors.dense(0.0)));
    +    JavaDStream<LabeledPoint> training =
    +      attachTestInputStream(ssc, Lists.newArrayList(trainingBatch, trainingBatch), 2);
    +    List<Tuple2<Integer, Vector>> testBatch = Lists.newArrayList(
    +      new Tuple2<Integer, Vector>(10, Vectors.dense(1.0)),
    +      new Tuple2<Integer, Vector>(11, Vectors.dense(0.0)));
    +    JavaPairDStream<Integer, Vector> test = JavaPairDStream.fromJavaDStream(
    +      attachTestInputStream(ssc, Lists.newArrayList(testBatch, testBatch), 2));
    +    StreamingLinearRegressionWithSGD slr = new StreamingLinearRegressionWithSGD()
    +      .setNumIterations(2)
    +      .setInitialWeights(Vectors.dense(0.0));
    +    slr.trainOn(training);
    +    JavaPairDStream<Integer, Double> prediction = slr.predictOnValues(test);
    --- End diff --
    
    Worth adding a basic test for accuracy, or maybe that's unnecessary duplication?


---
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-5601][MLLIB] make streaming linear algo...

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

    https://github.com/apache/spark/pull/4432#issuecomment-73314903
  
      [Test build #26943 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/26943/consoleFull) for   PR 4432 at commit [`2d7b357`](https://github.com/apache/spark/commit/2d7b357ef0363bf24364b6e704694953f3415392).
     * This patch merges cleanly.


---
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-5601][MLLIB] make streaming linear algo...

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

    https://github.com/apache/spark/pull/4432#issuecomment-73298105
  
      [Test build #26922 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/26922/consoleFull) for   PR 4432 at commit [`1f662b3`](https://github.com/apache/spark/commit/1f662b376a87f2f226759a5e97f8b9afe27c55d7).
     * 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-5601][MLLIB] make streaming linear algo...

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

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


---
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-5601][MLLIB] make streaming linear algo...

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

    https://github.com/apache/spark/pull/4432#issuecomment-73332847
  
      [Test build #26955 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/26955/consoleFull) for   PR 4432 at commit [`6a79b85`](https://github.com/apache/spark/commit/6a79b85396d435874e9e04233477dc8f946abb8a).
     * 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-5601][MLLIB] make streaming linear algo...

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

    https://github.com/apache/spark/pull/4432#issuecomment-73325722
  
      [Test build #26943 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/26943/consoleFull) for   PR 4432 at commit [`2d7b357`](https://github.com/apache/spark/commit/2d7b357ef0363bf24364b6e704694953f3415392).
     * 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-5601][MLLIB] make streaming linear algo...

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

    https://github.com/apache/spark/pull/4432#issuecomment-73323166
  
      [Test build #26955 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/26955/consoleFull) for   PR 4432 at commit [`6a79b85`](https://github.com/apache/spark/commit/6a79b85396d435874e9e04233477dc8f946abb8a).
     * This patch merges cleanly.


---
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-5601][MLLIB] make streaming linear algo...

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

    https://github.com/apache/spark/pull/4432#discussion_r24273989
  
    --- Diff: mllib/src/test/java/org/apache/spark/mllib/regression/JavaStreamingLinearRegressionSuite.java ---
    @@ -0,0 +1,80 @@
    +/*
    --- End diff --
    
    Do you want to add a similar `JavaStreamingLogisticRegressionSuite`? Given that the primary change here is to the base class (used by both linear and logistic regression), might make sense to include in the same 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-5601][MLLIB] make streaming linear algo...

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

    https://github.com/apache/spark/pull/4432#discussion_r24268769
  
    --- Diff: mllib/src/test/java/org/apache/spark/mllib/regression/JavaStreamingLinearRegressionSuite.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.mllib.regression;
    +
    +import java.io.Serializable;
    +import java.util.List;
    +
    +import scala.Tuple2;
    +
    +import com.google.common.collect.Lists;
    +import static org.apache.spark.streaming.JavaTestUtils.*;
    --- End diff --
    
    order


---
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-5601][MLLIB] make streaming linear algo...

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

    https://github.com/apache/spark/pull/4432#issuecomment-73298114
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/26922/
    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-5601][MLLIB] make streaming linear algo...

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

    https://github.com/apache/spark/pull/4432#discussion_r24276211
  
    --- Diff: mllib/src/test/java/org/apache/spark/mllib/regression/JavaStreamingLinearRegressionSuite.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.mllib.regression;
    +
    +import java.io.Serializable;
    +import java.util.List;
    +
    +import scala.Tuple2;
    +
    +import com.google.common.collect.Lists;
    +import org.junit.After;
    +import org.junit.Before;
    +import org.junit.Test;
    +
    +import org.apache.spark.SparkConf;
    +import org.apache.spark.mllib.linalg.Vector;
    +import org.apache.spark.mllib.linalg.Vectors;
    +import org.apache.spark.streaming.Duration;
    +import org.apache.spark.streaming.api.java.JavaDStream;
    +import org.apache.spark.streaming.api.java.JavaPairDStream;
    +import org.apache.spark.streaming.api.java.JavaStreamingContext;
    +import static org.apache.spark.streaming.JavaTestUtils.*;
    +
    +public class JavaStreamingLinearRegressionSuite implements Serializable {
    +
    +  protected transient JavaStreamingContext ssc;
    +
    +  @Before
    +  public void setUp() {
    +    SparkConf conf = new SparkConf()
    +      .setMaster("local[2]")
    +      .setAppName("test")
    +      .set("spark.streaming.clock", "org.apache.spark.streaming.util.ManualClock");
    +    ssc = new JavaStreamingContext(conf, new Duration(1000));
    +    ssc.checkpoint("checkpoint");
    +  }
    +
    +  @After
    +  public void tearDown() {
    +    ssc.stop();
    +    ssc = null;
    +  }
    +
    +  @Test
    +  @SuppressWarnings("unchecked")
    +  public void javaAPI() {
    +    List<LabeledPoint> trainingBatch = Lists.newArrayList(
    +      new LabeledPoint(1.0, Vectors.dense(1.0)),
    +      new LabeledPoint(0.0, Vectors.dense(0.0)));
    +    JavaDStream<LabeledPoint> training =
    +      attachTestInputStream(ssc, Lists.newArrayList(trainingBatch, trainingBatch), 2);
    +    List<Tuple2<Integer, Vector>> testBatch = Lists.newArrayList(
    +      new Tuple2<Integer, Vector>(10, Vectors.dense(1.0)),
    +      new Tuple2<Integer, Vector>(11, Vectors.dense(0.0)));
    +    JavaPairDStream<Integer, Vector> test = JavaPairDStream.fromJavaDStream(
    +      attachTestInputStream(ssc, Lists.newArrayList(testBatch, testBatch), 2));
    +    StreamingLinearRegressionWithSGD slr = new StreamingLinearRegressionWithSGD()
    +      .setNumIterations(2)
    +      .setInitialWeights(Vectors.dense(0.0));
    +    slr.trainOn(training);
    +    JavaPairDStream<Integer, Double> prediction = slr.predictOnValues(test);
    --- End diff --
    
    That test is in the Scala suite. This is just to test Java APIs. It is harder to maintain if we check accuracy in both places.


---
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-5601][MLLIB] make streaming linear algo...

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

    https://github.com/apache/spark/pull/4432#discussion_r24276343
  
    --- Diff: mllib/src/test/java/org/apache/spark/mllib/regression/JavaStreamingLinearRegressionSuite.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.mllib.regression;
    +
    +import java.io.Serializable;
    +import java.util.List;
    +
    +import scala.Tuple2;
    +
    +import com.google.common.collect.Lists;
    +import org.junit.After;
    +import org.junit.Before;
    +import org.junit.Test;
    +
    +import org.apache.spark.SparkConf;
    +import org.apache.spark.mllib.linalg.Vector;
    +import org.apache.spark.mllib.linalg.Vectors;
    +import org.apache.spark.streaming.Duration;
    +import org.apache.spark.streaming.api.java.JavaDStream;
    +import org.apache.spark.streaming.api.java.JavaPairDStream;
    +import org.apache.spark.streaming.api.java.JavaStreamingContext;
    +import static org.apache.spark.streaming.JavaTestUtils.*;
    +
    +public class JavaStreamingLinearRegressionSuite implements Serializable {
    +
    +  protected transient JavaStreamingContext ssc;
    +
    +  @Before
    +  public void setUp() {
    +    SparkConf conf = new SparkConf()
    +      .setMaster("local[2]")
    +      .setAppName("test")
    +      .set("spark.streaming.clock", "org.apache.spark.streaming.util.ManualClock");
    +    ssc = new JavaStreamingContext(conf, new Duration(1000));
    +    ssc.checkpoint("checkpoint");
    +  }
    +
    +  @After
    +  public void tearDown() {
    +    ssc.stop();
    +    ssc = null;
    +  }
    +
    +  @Test
    +  @SuppressWarnings("unchecked")
    +  public void javaAPI() {
    +    List<LabeledPoint> trainingBatch = Lists.newArrayList(
    +      new LabeledPoint(1.0, Vectors.dense(1.0)),
    +      new LabeledPoint(0.0, Vectors.dense(0.0)));
    +    JavaDStream<LabeledPoint> training =
    +      attachTestInputStream(ssc, Lists.newArrayList(trainingBatch, trainingBatch), 2);
    +    List<Tuple2<Integer, Vector>> testBatch = Lists.newArrayList(
    +      new Tuple2<Integer, Vector>(10, Vectors.dense(1.0)),
    +      new Tuple2<Integer, Vector>(11, Vectors.dense(0.0)));
    +    JavaPairDStream<Integer, Vector> test = JavaPairDStream.fromJavaDStream(
    +      attachTestInputStream(ssc, Lists.newArrayList(testBatch, testBatch), 2));
    +    StreamingLinearRegressionWithSGD slr = new StreamingLinearRegressionWithSGD()
    +      .setNumIterations(2)
    +      .setInitialWeights(Vectors.dense(0.0));
    +    slr.trainOn(training);
    +    JavaPairDStream<Integer, Double> prediction = slr.predictOnValues(test);
    --- End diff --
    
    Cool, agreed.


---
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