Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-3128][MLLIB] Use streaming test suite for StreamingLR #2037

Closed

Conversation

freeman-lab
Copy link
Contributor

Refactored tests for streaming linear regression to use existing streaming test utilities. Summary of changes:

  • Made mllib depend on tests from streaming
  • Rewrote accuracy and convergence tests to use setupStreams and runStreams
  • Added new test for the accuracy of predictions generated by predictOnValue

These tests should run faster, be easier to extend/maintain, and provide a reference for new tests.

@mengxr @tdas

- Test predictOnValues for accuracy on a test stream
- Made mllib depend on tests from streaming
- Rewrote all streamingLR tests to use the setupStreams & runStreams
functions
@mengxr
Copy link
Contributor

mengxr commented Aug 19, 2014

Jenkins, test this please.

@@ -242,7 +242,7 @@ trait TestSuiteBase extends FunSuite with BeforeAndAfter with Logging {
logInfo("numBatches = " + numBatches + ", numExpectedOutput = " + numExpectedOutput)

// Get the output buffer
val outputStream = ssc.graph.getOutputStreams.head.asInstanceOf[TestOutputStreamWithPartitions[V]]
val outputStream = ssc.graph.getOutputStreams.filter(_.isInstanceOf[TestOutputStreamWithPartitions[_]]).head.asInstanceOf[TestOutputStreamWithPartitions[V]]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is over 100 characters.

@SparkQA
Copy link

SparkQA commented Aug 19, 2014

QA tests have started for PR 2037 at commit 50eb0bf.

  • This patch merges cleanly.


// compute the mean absolute error and check that it's always less than 0.1
val errors = output.map(batch => batch.map(
p => math.abs(p._1 - p._2)).reduce(_+_) / nPoints.toDouble)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.reduce(_+_) -> sum

Then it could be fit into one line:

val errors = output.map(batch => batch.map(p => math.abs(p._1 - p._2)).sum / nPoints)

sum returns Double so we don't need to call toDouble explicitly.

@SparkQA
Copy link

SparkQA commented Aug 19, 2014

QA tests have finished for PR 2037 at commit 50eb0bf.

  • This patch fails unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@freeman-lab
Copy link
Contributor Author

Jenkins, test this please.

@SparkQA
Copy link

SparkQA commented Aug 19, 2014

QA tests have started for PR 2037 at commit e851ca7.

  • This patch merges cleanly.

@SparkQA
Copy link

SparkQA commented Aug 19, 2014

QA tests have started for PR 2037 at commit e851ca7.

  • This patch merges cleanly.

// compute the mean absolute error and check that it's always less than 0.1
val errors = output.map(batch => batch.map(p => math.abs(p._1 - p._2)).sum / nPoints)
assert(errors.forall(x => x <= 0.1))

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: extra line

@tdas
Copy link
Contributor

tdas commented Aug 19, 2014

LGTM, if tests pass. Small nits, which can be ignored if there is nothing else to be changed.

@SparkQA
Copy link

SparkQA commented Aug 19, 2014

QA tests have finished for PR 2037 at commit e851ca7.

  • This patch passes unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Aug 19, 2014

QA tests have finished for PR 2037 at commit e851ca7.

  • This patch passes unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@freeman-lab
Copy link
Contributor Author

@mengxr @tdas thanks for reviewing!

@asfgit asfgit closed this in 31f0b07 Aug 19, 2014
asfgit pushed a commit that referenced this pull request Aug 19, 2014
Refactored tests for streaming linear regression to use existing  streaming test utilities. Summary of changes:
- Made ``mllib`` depend on tests from ``streaming``
- Rewrote accuracy and convergence tests to use ``setupStreams`` and ``runStreams``
- Added new test for the accuracy of predictions generated by ``predictOnValue``

These tests should run faster, be easier to extend/maintain, and provide a reference for new tests.

mengxr tdas

Author: freeman <the.freeman.lab@gmail.com>

Closes #2037 from freeman-lab/streamingLR-predict-tests and squashes the following commits:

e851ca7 [freeman] Fixed long lines
50eb0bf [freeman] Refactored tests to use streaming test tools
32c43c2 [freeman] Added test for prediction

(cherry picked from commit 31f0b07)
Signed-off-by: Tathagata Das <tathagata.das1565@gmail.com>
@tdas
Copy link
Contributor

tdas commented Aug 19, 2014

Thanks a lot @freeman-lab

@mengxr
Copy link
Contributor

mengxr commented Aug 19, 2014

@tdas It seems that this creates a folder called checkpoint under mllib and breaks Jenkins build.

xiliu82 pushed a commit to xiliu82/spark that referenced this pull request Sep 4, 2014
Refactored tests for streaming linear regression to use existing  streaming test utilities. Summary of changes:
- Made ``mllib`` depend on tests from ``streaming``
- Rewrote accuracy and convergence tests to use ``setupStreams`` and ``runStreams``
- Added new test for the accuracy of predictions generated by ``predictOnValue``

These tests should run faster, be easier to extend/maintain, and provide a reference for new tests.

mengxr tdas

Author: freeman <the.freeman.lab@gmail.com>

Closes apache#2037 from freeman-lab/streamingLR-predict-tests and squashes the following commits:

e851ca7 [freeman] Fixed long lines
50eb0bf [freeman] Refactored tests to use streaming test tools
32c43c2 [freeman] Added test for prediction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants