You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by MechCoder <gi...@git.apache.org> on 2015/03/05 10:01:30 UTC
[GitHub] spark pull request: [SPARK-6025] [MLlib] Add helper method evaluat...
GitHub user MechCoder opened a pull request:
https://github.com/apache/spark/pull/4906
[SPARK-6025] [MLlib] Add helper method evaluateEachIteration to extract learning curve
Added evaluateEachIteration to allow the user to manually extract the error for each iteration of GradientBoosting. The internal optimisation can be dealt with later.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/MechCoder/spark spark-6025
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/4906.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 #4906
----
commit 26b2e916355956100192a884f88e7a997e58165a
Author: MechCoder <ma...@gmail.com>
Date: 2015-03-05T08:58:43Z
[SPARK-6025] Add helper method evaluateEachIteration to extract learning curve
----
---
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-6025] [MLlib] Add helper method evaluat...
Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:
https://github.com/apache/spark/pull/4906#issuecomment-77340361
[Test build #28286 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/28286/consoleFull) for PR 4906 at commit [`dbda033`](https://github.com/apache/spark/commit/dbda03302bedf52913582030da3eac567c5d8775).
* 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-6025] [MLlib] Add helper method evaluat...
Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:
https://github.com/apache/spark/pull/4906#issuecomment-77328932
[Test build #28285 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/28285/consoleFull) for PR 4906 at commit [`26b2e91`](https://github.com/apache/spark/commit/26b2e916355956100192a884f88e7a997e58165a).
* 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-6025] [MLlib] Add helper method evaluat...
Posted by MechCoder <gi...@git.apache.org>.
Github user MechCoder commented on the pull request:
https://github.com/apache/spark/pull/4906#issuecomment-78221708
@jkbradley I have addressed all your comments.
I have a query regarding the use of mapPartition vs map. I see that mapPartition is preferred when there is a huge overhead for each task, is that right?
---
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-6025] [MLlib] Add helper method evaluat...
Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:
https://github.com/apache/spark/pull/4906#issuecomment-82134395
[Test build #28705 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/28705/consoleFull) for PR 4906 at commit [`67146ab`](https://github.com/apache/spark/commit/67146abf82938425b33d52238ef0e5e72ed8ca6e).
* 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-6025] [MLlib] Add helper method evaluat...
Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:
https://github.com/apache/spark/pull/4906#issuecomment-82184112
[Test build #28705 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/28705/consoleFull) for PR 4906 at commit [`67146ab`](https://github.com/apache/spark/commit/67146abf82938425b33d52238ef0e5e72ed8ca6e).
* 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-6025] [MLlib] Add helper method evaluat...
Posted by jkbradley <gi...@git.apache.org>.
Github user jkbradley commented on the pull request:
https://github.com/apache/spark/pull/4906#issuecomment-78177347
Thanks for the updates! I made a detailed pass. The general layout looks fine.
---
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-6025] [MLlib] Add helper method evaluat...
Posted by jkbradley <gi...@git.apache.org>.
Github user jkbradley commented on a diff in the pull request:
https://github.com/apache/spark/pull/4906#discussion_r26179897
--- Diff: mllib/src/main/scala/org/apache/spark/mllib/tree/model/treeEnsembleModels.scala ---
@@ -108,6 +110,53 @@ class GradientBoostedTreesModel(
}
override protected def formatVersion: String = TreeEnsembleModel.SaveLoadV1_0.thisFormatVersion
+
+ /**
+ * Method to compute error or loss for every iteration of gradient boosting.
+ * @param data: RDD of [[org.apache.spark.mllib.regression.LabeledPoint]]
+ * @param loss: evaluation metric.
+ * @return an array with index i having the losses or errors for the ensemble
+ * containing trees 1 to i + 1
+ */
+ def evaluateEachIteration(
+ data: RDD[LabeledPoint],
+ loss: Loss) : Array[Double] = {
+
+ val sc = data.sparkContext
+ val remappedData = algo match {
+ case Classification => data.map(x => new LabeledPoint((x.label * 2) - 1, x.features))
+ case _ => data
+ }
+ val initialTree = trees(0)
--- End diff --
remove? only used once
---
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-6025] [MLlib] Add helper method evaluat...
Posted by jkbradley <gi...@git.apache.org>.
Github user jkbradley commented on a diff in the pull request:
https://github.com/apache/spark/pull/4906#discussion_r26179909
--- Diff: mllib/src/main/scala/org/apache/spark/mllib/tree/model/treeEnsembleModels.scala ---
@@ -108,6 +110,53 @@ class GradientBoostedTreesModel(
}
override protected def formatVersion: String = TreeEnsembleModel.SaveLoadV1_0.thisFormatVersion
+
+ /**
+ * Method to compute error or loss for every iteration of gradient boosting.
+ * @param data: RDD of [[org.apache.spark.mllib.regression.LabeledPoint]]
+ * @param loss: evaluation metric.
+ * @return an array with index i having the losses or errors for the ensemble
+ * containing trees 1 to i + 1
+ */
+ def evaluateEachIteration(
+ data: RDD[LabeledPoint],
+ loss: Loss) : Array[Double] = {
+
+ val sc = data.sparkContext
+ val remappedData = algo match {
+ case Classification => data.map(x => new LabeledPoint((x.label * 2) - 1, x.features))
+ case _ => data
+ }
+ val initialTree = trees(0)
+ val numIterations = trees.length
+ val evaluationArray = Array.fill(numIterations)(0.0)
+
+ // Initial weight is 1.0
+ var predictionErrorModel = remappedData.map {i =>
+ val pred = initialTree.predict(i.features)
+ val error = loss.computeError(i, pred)
+ (pred, error)
+ }
+ evaluationArray(0) = predictionErrorModel.values.mean()
+
+ // Avoid the model being copied across numIterations.
+ val broadcastTrees = sc.broadcast(trees)
+ val broadcastWeights = sc.broadcast(treeWeights)
+
+ (1 until numIterations).map {nTree =>
--- End diff --
space after {
---
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-6025] [MLlib] Add helper method evaluat...
Posted by jkbradley <gi...@git.apache.org>.
Github user jkbradley commented on a diff in the pull request:
https://github.com/apache/spark/pull/4906#discussion_r26179888
--- Diff: mllib/src/main/scala/org/apache/spark/mllib/tree/loss/Loss.scala ---
@@ -49,4 +49,14 @@ trait Loss extends Serializable {
*/
def computeError(model: TreeEnsembleModel, data: RDD[LabeledPoint]): Double
--- End diff --
Provide default implementation using other computeError, and then remove overridden copies from child 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-6025] [MLlib] Add helper method evaluat...
Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:
https://github.com/apache/spark/pull/4906#issuecomment-78147927
Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/28435/
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-6025] [MLlib] Add helper method evaluat...
Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:
https://github.com/apache/spark/pull/4906#issuecomment-78221714
[Test build #28469 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/28469/consoleFull) for PR 4906 at commit [`62cad83`](https://github.com/apache/spark/commit/62cad8367c44a696030a50dee35de264ecc3f9cb).
* 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-6025] [MLlib] Add helper method evaluat...
Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:
https://github.com/apache/spark/pull/4906#issuecomment-78234289
[Test build #28471 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/28471/consoleFull) for PR 4906 at commit [`6e8aa10`](https://github.com/apache/spark/commit/6e8aa106ff95b446b308996edca98cad8f410813).
* 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-6025] [MLlib] Add helper method evaluat...
Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:
https://github.com/apache/spark/pull/4906#issuecomment-77329529
[Test build #28286 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/28286/consoleFull) for PR 4906 at commit [`dbda033`](https://github.com/apache/spark/commit/dbda03302bedf52913582030da3eac567c5d8775).
* 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-6025] [MLlib] Add helper method evaluat...
Posted by jkbradley <gi...@git.apache.org>.
Github user jkbradley commented on a diff in the pull request:
https://github.com/apache/spark/pull/4906#discussion_r26179883
--- Diff: mllib/src/main/scala/org/apache/spark/mllib/tree/loss/AbsoluteError.scala ---
@@ -61,4 +61,18 @@ object AbsoluteError extends Loss {
math.abs(err)
}.mean()
}
+
+ /**
--- End diff --
No need for doc; it will be inherited from the overridden method (here and in other 2 loss 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-6025] [MLlib] Add helper method evaluat...
Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:
https://github.com/apache/spark/pull/4906#issuecomment-77339577
Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/28285/
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-6025] [MLlib] Add helper method evaluat...
Posted by jkbradley <gi...@git.apache.org>.
Github user jkbradley commented on a diff in the pull request:
https://github.com/apache/spark/pull/4906#discussion_r26179903
--- Diff: mllib/src/main/scala/org/apache/spark/mllib/tree/model/treeEnsembleModels.scala ---
@@ -108,6 +110,53 @@ class GradientBoostedTreesModel(
}
override protected def formatVersion: String = TreeEnsembleModel.SaveLoadV1_0.thisFormatVersion
+
+ /**
+ * Method to compute error or loss for every iteration of gradient boosting.
+ * @param data: RDD of [[org.apache.spark.mllib.regression.LabeledPoint]]
+ * @param loss: evaluation metric.
+ * @return an array with index i having the losses or errors for the ensemble
+ * containing trees 1 to i + 1
+ */
+ def evaluateEachIteration(
+ data: RDD[LabeledPoint],
+ loss: Loss) : Array[Double] = {
+
+ val sc = data.sparkContext
+ val remappedData = algo match {
+ case Classification => data.map(x => new LabeledPoint((x.label * 2) - 1, x.features))
+ case _ => data
+ }
+ val initialTree = trees(0)
+ val numIterations = trees.length
+ val evaluationArray = Array.fill(numIterations)(0.0)
+
+ // Initial weight is 1.0
--- End diff --
may as well use initial weight explicitly in case that changes for some reason in the future
---
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-6025] [MLlib] Add helper method evaluat...
Posted by MechCoder <gi...@git.apache.org>.
Github user MechCoder commented on the pull request:
https://github.com/apache/spark/pull/4906#issuecomment-84258418
Just to clarify, the raw prediction value (w' * x) should vary from -infinity to +infinity? So that when it's as large as possible, the contribution to log loss is zero?
---
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-6025] [MLlib] Add helper method evaluat...
Posted by jkbradley <gi...@git.apache.org>.
Github user jkbradley commented on the pull request:
https://github.com/apache/spark/pull/4906#issuecomment-80758187
I think that's the last to-do item.
---
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-6025] [MLlib] Add helper method evaluat...
Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:
https://github.com/apache/spark/pull/4906#issuecomment-78133176
[Test build #28436 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/28436/consoleFull) for PR 4906 at commit [`bc99ac6`](https://github.com/apache/spark/commit/bc99ac68fdd81e5f0569a9cfd2d1eb97498885b6).
* 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-6025] [MLlib] Add helper method evaluat...
Posted by jkbradley <gi...@git.apache.org>.
Github user jkbradley commented on a diff in the pull request:
https://github.com/apache/spark/pull/4906#discussion_r26439845
--- Diff: mllib/src/main/scala/org/apache/spark/mllib/tree/loss/AbsoluteError.scala ---
@@ -61,4 +61,18 @@ object AbsoluteError extends Loss {
math.abs(err)
}.mean()
}
+
+ /**
--- End diff --
I think it's OK for the doc for gradient() and computeError() to be generic as long as the doc for the loss classes describes the specific loss function.
---
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-6025] [MLlib] Add helper method evaluat...
Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:
https://github.com/apache/spark/pull/4906#issuecomment-80652118
[Test build #28611 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/28611/consoleFull) for PR 4906 at commit [`c04a430`](https://github.com/apache/spark/commit/c04a4305dc2e584affd90df2722d4ab534a67273).
* 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-6025] [MLlib] Add helper method evaluat...
Posted by jkbradley <gi...@git.apache.org>.
Github user jkbradley commented on the pull request:
https://github.com/apache/spark/pull/4906#issuecomment-84196807
Your query may be caused by my confusion above. To answer your query, the prediction F(x) should be the raw prediction, not the discrete -1/+1 value.
---
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-6025] [MLlib] Add helper method evaluat...
Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:
https://github.com/apache/spark/pull/4906#issuecomment-80861294
Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/28621/
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-6025] [MLlib] Add helper method evaluat...
Posted by jkbradley <gi...@git.apache.org>.
Github user jkbradley commented on a diff in the pull request:
https://github.com/apache/spark/pull/4906#discussion_r26439865
--- Diff: mllib/src/main/scala/org/apache/spark/mllib/tree/loss/Loss.scala ---
@@ -47,6 +47,18 @@ trait Loss extends Serializable {
* @param data Training dataset: RDD of [[org.apache.spark.mllib.regression.LabeledPoint]].
* @return Measure of model error on data
*/
- def computeError(model: TreeEnsembleModel, data: RDD[LabeledPoint]): Double
+ def computeError(model: TreeEnsembleModel, data: RDD[LabeledPoint]): Double = {
+ data.map(point => computeError(model.predict(point.features), point)).mean()
+ }
+
+ /**
+ * Method to calculate loss when the predictions are already known.
+ * Note: This method is used in the method evaluateEachIteration to avoid recomputing the
+ * predicted values from previously fit trees.
+ * @param prediction Predicted label.
+ * @param datum LabeledPoint
+ * @return Measure of model error on datapoint.
+ */
+ def computeError(prediction: Double, datum: LabeledPoint): Double
--- End diff --
This should really take "label" instead of "datum" since the feature should never be needed.
---
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-6025] [MLlib] Add helper method evaluat...
Posted by MechCoder <gi...@git.apache.org>.
Github user MechCoder commented on the pull request:
https://github.com/apache/spark/pull/4906#issuecomment-77329223
cc @jkbradley Sorry for the mess! This should be what we want.
---
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-6025] [MLlib] Add helper method evaluat...
Posted by jkbradley <gi...@git.apache.org>.
Github user jkbradley commented on the pull request:
https://github.com/apache/spark/pull/4906#issuecomment-80639905
That should cover it! It will still be a couple of days before my API PR is ready, so we should be able to finish and merge this before any conflicts arise. 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-6025] [MLlib] Add helper method evaluat...
Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:
https://github.com/apache/spark/pull/4906#issuecomment-78228892
Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/28469/
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-6025] [MLlib] Add helper method evaluat...
Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:
https://github.com/apache/spark/pull/4906#issuecomment-78221177
[Test build #28468 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/28468/consoleFull) for PR 4906 at commit [`ebbd1ad`](https://github.com/apache/spark/commit/ebbd1ad3ef1f8f1b95febdd8daac3f14c804fbad).
* 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-6025] [MLlib] Add helper method evaluat...
Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:
https://github.com/apache/spark/pull/4906#issuecomment-78234302
Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/28471/
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-6025] [MLlib] Add helper method evaluat...
Posted by jkbradley <gi...@git.apache.org>.
Github user jkbradley commented on a diff in the pull request:
https://github.com/apache/spark/pull/4906#discussion_r26539550
--- Diff: mllib/src/main/scala/org/apache/spark/mllib/tree/model/treeEnsembleModels.scala ---
@@ -108,6 +110,58 @@ class GradientBoostedTreesModel(
}
override protected def formatVersion: String = TreeEnsembleModel.SaveLoadV1_0.thisFormatVersion
+
+ /**
+ * Method to compute error or loss for every iteration of gradient boosting.
+ * @param data RDD of [[org.apache.spark.mllib.regression.LabeledPoint]]
+ * @param loss evaluation metric.
+ * @return an array with index i having the losses or errors for the ensemble
+ * containing trees 1 to i + 1
--- End diff --
Minor: Use 0-based indexing for doc: "containing trees 0 to i"
Or just say "containing the first i+1 trees"
---
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-6025] [MLlib] Add helper method evaluat...
Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:
https://github.com/apache/spark/pull/4906#issuecomment-78148909
Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/28436/
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-6025] [MLlib] Add helper method evaluat...
Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:
https://github.com/apache/spark/pull/4906#issuecomment-77340367
Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/28286/
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-6025] [MLlib] Add helper method evaluat...
Posted by jkbradley <gi...@git.apache.org>.
Github user jkbradley commented on a diff in the pull request:
https://github.com/apache/spark/pull/4906#discussion_r26179911
--- Diff: mllib/src/main/scala/org/apache/spark/mllib/tree/model/treeEnsembleModels.scala ---
@@ -108,6 +110,53 @@ class GradientBoostedTreesModel(
}
override protected def formatVersion: String = TreeEnsembleModel.SaveLoadV1_0.thisFormatVersion
+
+ /**
+ * Method to compute error or loss for every iteration of gradient boosting.
+ * @param data: RDD of [[org.apache.spark.mllib.regression.LabeledPoint]]
+ * @param loss: evaluation metric.
+ * @return an array with index i having the losses or errors for the ensemble
+ * containing trees 1 to i + 1
+ */
+ def evaluateEachIteration(
+ data: RDD[LabeledPoint],
+ loss: Loss) : Array[Double] = {
+
+ val sc = data.sparkContext
+ val remappedData = algo match {
+ case Classification => data.map(x => new LabeledPoint((x.label * 2) - 1, x.features))
+ case _ => data
+ }
+ val initialTree = trees(0)
+ val numIterations = trees.length
+ val evaluationArray = Array.fill(numIterations)(0.0)
+
+ // Initial weight is 1.0
+ var predictionErrorModel = remappedData.map {i =>
+ val pred = initialTree.predict(i.features)
+ val error = loss.computeError(i, pred)
+ (pred, error)
+ }
+ evaluationArray(0) = predictionErrorModel.values.mean()
+
+ // Avoid the model being copied across numIterations.
+ val broadcastTrees = sc.broadcast(trees)
+ val broadcastWeights = sc.broadcast(treeWeights)
+
+ (1 until numIterations).map {nTree =>
+ predictionErrorModel = (remappedData zip predictionErrorModel) map {
--- End diff --
I would use mapPartitions. Before iterating over the partition elements, extract the trees and weights from the broadcast variables. I believe that reduces overhead a little.
Also, try to avoid infix notation since non-Scala people may not be used to it:
```
remappedData.zip(predictionErrorModel)
```
---
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-6025] [MLlib] Add helper method evaluat...
Posted by MechCoder <gi...@git.apache.org>.
Github user MechCoder commented on the pull request:
https://github.com/apache/spark/pull/4906#issuecomment-84288948
Also, I could wait for the internal optimization till the tree API PR is finished. Also let me know, if you need a help with reviewing the tree API PR (though admittedly, it will help me more by reading the code rather than you :P)
---
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-6025] [MLlib] Add helper method evaluat...
Posted by jkbradley <gi...@git.apache.org>.
Github user jkbradley commented on a diff in the pull request:
https://github.com/apache/spark/pull/4906#discussion_r26179919
--- Diff: mllib/src/test/scala/org/apache/spark/mllib/tree/GradientBoostedTreesSuite.scala ---
@@ -188,6 +189,17 @@ class GradientBoostedTreesSuite extends FunSuite with MLlibTestSparkContext {
}
}
assert(errorWithValidation <= errorWithoutValidation)
+
+ // Test that results from evaluateEachIteration comply with runWithValidation.
+ // Note that convergenceTol is set to 0.0
+ val evaluationArray = gbt.evaluateEachIteration(validateRdd, loss)
+ assert(evaluationArray.length === numIterations)
+ assert(evaluationArray(numTrees) > evaluationArray(numTrees - 1))
+ var i = 1
+ while (i < numTrees) {
+ assert(evaluationArray(i) < evaluationArray(i - 1))
--- End diff --
small issue: < should be <=
---
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-6025] [MLlib] Add helper method evaluat...
Posted by MechCoder <gi...@git.apache.org>.
Github user MechCoder commented on the pull request:
https://github.com/apache/spark/pull/4906#issuecomment-81177042
But are accessing values from the broadcasted variables expensive enough that placing the lines under `mapPartitions` give enough benefit?
---
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-6025] [MLlib] Add helper method evaluat...
Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:
https://github.com/apache/spark/pull/4906#issuecomment-80823393
[Test build #28621 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/28621/consoleFull) for PR 4906 at commit [`352001f`](https://github.com/apache/spark/commit/352001fc81912e273159580225b3db2a1cac06aa).
* 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-6025] [MLlib] Add helper method evaluat...
Posted by MechCoder <gi...@git.apache.org>.
Github user MechCoder commented on the pull request:
https://github.com/apache/spark/pull/4906#issuecomment-82982129
@jkbradley I have a silly query that I cannot refrain from asking.
If a point is predicted correctly, then the contribution of log loss due to that point should be zero right?
However, if we take the log loss function, log(1+exp(−2y * F(x))) , let us say that y is 1, and F(x) which is the predicted label is also 1, then it contributes log(1 + exp(-2)) ~ 0.126 to the loss.
The log loss that I am familiar with, i.e log(1 + exp(-y * w' * x)) (where w is the weight and x is the feature vector), the contribution to the log loss approaches zero as w * x approaches infinity.
However here w * x is continuous as compared to F(x) which is discrete.
---
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-6025] [MLlib] Add helper method evaluat...
Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:
https://github.com/apache/spark/pull/4906#issuecomment-78233025
[Test build #28470 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/28470/consoleFull) for PR 4906 at commit [`be61ca1`](https://github.com/apache/spark/commit/be61ca12a8ec2863fc12bccbd876231b0e3d1ce5).
* 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-6025] [MLlib] Add helper method evaluat...
Posted by jkbradley <gi...@git.apache.org>.
Github user jkbradley commented on a diff in the pull request:
https://github.com/apache/spark/pull/4906#discussion_r26179890
--- Diff: mllib/src/main/scala/org/apache/spark/mllib/tree/loss/Loss.scala ---
@@ -49,4 +49,14 @@ trait Loss extends Serializable {
*/
def computeError(model: TreeEnsembleModel, data: RDD[LabeledPoint]): Double
+ /**
+ * Method to calculate loss when the predictions are already known.
+ * Note: This method is used in the method evaluateEachIteration to avoid recomputing the
+ * predicted values from previously fit trees.
+ * @param datum: LabeledPoint
--- End diff --
no colon after param name (here and elsewhere)
---
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-6025] [MLlib] Add helper method evaluat...
Posted by MechCoder <gi...@git.apache.org>.
Github user MechCoder commented on the pull request:
https://github.com/apache/spark/pull/4906#issuecomment-78934760
@jkbradley Would you want to merge this PR before the other one? 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-6025] [MLlib] Add helper method evaluat...
Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:
https://github.com/apache/spark/pull/4906#issuecomment-78148892
[Test build #28436 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/28436/consoleFull) for PR 4906 at commit [`bc99ac6`](https://github.com/apache/spark/commit/bc99ac68fdd81e5f0569a9cfd2d1eb97498885b6).
* 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-6025] [MLlib] Add helper method evaluat...
Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:
https://github.com/apache/spark/pull/4906#issuecomment-78228888
[Test build #28469 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/28469/consoleFull) for PR 4906 at commit [`62cad83`](https://github.com/apache/spark/commit/62cad8367c44a696030a50dee35de264ecc3f9cb).
* This patch **fails Spark unit 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-6025] [MLlib] Add helper method evaluat...
Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:
https://github.com/apache/spark/pull/4906#issuecomment-78222938
[Test build #28470 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/28470/consoleFull) for PR 4906 at commit [`be61ca1`](https://github.com/apache/spark/commit/be61ca12a8ec2863fc12bccbd876231b0e3d1ce5).
* 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-6025] [MLlib] Add helper method evaluat...
Posted by jkbradley <gi...@git.apache.org>.
Github user jkbradley commented on a diff in the pull request:
https://github.com/apache/spark/pull/4906#discussion_r26442790
--- Diff: mllib/src/main/scala/org/apache/spark/mllib/tree/model/treeEnsembleModels.scala ---
@@ -108,6 +110,58 @@ class GradientBoostedTreesModel(
}
override protected def formatVersion: String = TreeEnsembleModel.SaveLoadV1_0.thisFormatVersion
+
+ /**
+ * Method to compute error or loss for every iteration of gradient boosting.
+ * @param data RDD of [[org.apache.spark.mllib.regression.LabeledPoint]]
+ * @param loss evaluation metric.
+ * @return an array with index i having the losses or errors for the ensemble
+ * containing trees 1 to i + 1
+ */
+ def evaluateEachIteration(
+ data: RDD[LabeledPoint],
+ loss: Loss): Array[Double] = {
+
+ val sc = data.sparkContext
+ val remappedData = algo match {
+ case Classification => data.map(x => new LabeledPoint((x.label * 2) - 1, x.features))
+ case _ => data
+ }
+
+ val numIterations = trees.length
+ val evaluationArray = Array.fill(numIterations)(0.0)
+
+ var predictionAndError: RDD[(Double, Double)] = remappedData.map { i =>
+ val pred = treeWeights(0) * trees(0).predict(i.features)
+ val error = loss.computeError(pred, i.label)
+ (pred, error)
+ }
+ evaluationArray(0) = predictionAndError.values.mean()
+
+ // Avoid the model being copied across numIterations.
+ val broadcastTrees = sc.broadcast(trees)
+ val broadcastWeights = sc.broadcast(treeWeights)
+
+ (1 until numIterations).map { nTree =>
+ val currentTree = broadcastTrees.value(nTree)
--- End diff --
OOPS! I didn't even notice that this and the next line were outside of the mapPartitions. They need to be inside the closure (before "iter.map") for broadcasting to accomplish anything.
---
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-6025] [MLlib] Add helper method evaluat...
Posted by jkbradley <gi...@git.apache.org>.
Github user jkbradley commented on a diff in the pull request:
https://github.com/apache/spark/pull/4906#discussion_r26439847
--- Diff: mllib/src/main/scala/org/apache/spark/mllib/tree/model/treeEnsembleModels.scala ---
@@ -108,6 +110,58 @@ class GradientBoostedTreesModel(
}
override protected def formatVersion: String = TreeEnsembleModel.SaveLoadV1_0.thisFormatVersion
+
+ /**
+ * Method to compute error or loss for every iteration of gradient boosting.
+ * @param data RDD of [[org.apache.spark.mllib.regression.LabeledPoint]]
+ * @param loss evaluation metric.
+ * @return an array with index i having the losses or errors for the ensemble
+ * containing trees 1 to i + 1
+ */
+ def evaluateEachIteration(
+ data: RDD[LabeledPoint],
+ loss: Loss): Array[Double] = {
+
+ val sc = data.sparkContext
+ val remappedData = algo match {
+ case Classification => data.map(x => new LabeledPoint((x.label * 2) - 1, x.features))
+ case _ => data
+ }
+
+ val numIterations = trees.length
+ val evaluationArray = Array.fill(numIterations)(0.0)
+
+ var predictionAndError: RDD[(Double, Double)] = remappedData.map { i =>
+ val pred = treeWeights(0) * trees(0).predict(i.features)
+ val error = loss.computeError(pred, i)
+ (pred, error)
+ }
+ evaluationArray(0) = predictionAndError.values.mean()
+
+ // Avoid the model being copied across numIterations.
+ val broadcastTrees = sc.broadcast(trees)
+ val broadcastWeights = sc.broadcast(treeWeights)
+
+ (1 until numIterations).map { nTree =>
+ val currentTree = broadcastTrees.value(nTree)
+ val currentTreeWeight = broadcastWeights.value(nTree)
+ predictionAndError = remappedData.zip(predictionAndError).mapPartitions { iter =>
+ iter map {
--- End diff --
No infix notation: "iter.map"
Or you could make it even shorter by changing "iter => iter map {" to "_.map {"
---
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-6025] [MLlib] Add helper method evaluat...
Posted by MechCoder <gi...@git.apache.org>.
Github user MechCoder commented on the pull request:
https://github.com/apache/spark/pull/4906#issuecomment-80823114
@jkbradley 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-6025] [MLlib] Add helper method evaluat...
Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:
https://github.com/apache/spark/pull/4906#issuecomment-77339570
[Test build #28285 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/28285/consoleFull) for PR 4906 at commit [`26b2e91`](https://github.com/apache/spark/commit/26b2e916355956100192a884f88e7a997e58165a).
* 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-6025] [MLlib] Add helper method evaluat...
Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:
https://github.com/apache/spark/pull/4906#issuecomment-78227751
Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/28468/
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-6025] [MLlib] Add helper method evaluat...
Posted by jkbradley <gi...@git.apache.org>.
Github user jkbradley commented on the pull request:
https://github.com/apache/spark/pull/4906#issuecomment-84443435
When ```y * w' * x``` (including multiplying by the -1/+1 label y) is very large, the contribution is close to zero.
It might be good to wait for the internal optimization. Thanks!
I'll ping you on the PR once I update it again.
---
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-6025] [MLlib] Add helper method evaluat...
Posted by jkbradley <gi...@git.apache.org>.
Github user jkbradley commented on the pull request:
https://github.com/apache/spark/pull/4906#issuecomment-84198344
LGTM; I'll merge this 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-6025] [MLlib] Add helper method evaluat...
Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:
https://github.com/apache/spark/pull/4906#issuecomment-78223500
[Test build #28471 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/28471/consoleFull) for PR 4906 at commit [`6e8aa10`](https://github.com/apache/spark/commit/6e8aa106ff95b446b308996edca98cad8f410813).
* 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-6025] [MLlib] Add helper method evaluat...
Posted by jkbradley <gi...@git.apache.org>.
Github user jkbradley commented on a diff in the pull request:
https://github.com/apache/spark/pull/4906#discussion_r26179907
--- Diff: mllib/src/main/scala/org/apache/spark/mllib/tree/model/treeEnsembleModels.scala ---
@@ -108,6 +110,53 @@ class GradientBoostedTreesModel(
}
override protected def formatVersion: String = TreeEnsembleModel.SaveLoadV1_0.thisFormatVersion
+
+ /**
+ * Method to compute error or loss for every iteration of gradient boosting.
+ * @param data: RDD of [[org.apache.spark.mllib.regression.LabeledPoint]]
+ * @param loss: evaluation metric.
+ * @return an array with index i having the losses or errors for the ensemble
+ * containing trees 1 to i + 1
+ */
+ def evaluateEachIteration(
+ data: RDD[LabeledPoint],
+ loss: Loss) : Array[Double] = {
+
+ val sc = data.sparkContext
+ val remappedData = algo match {
+ case Classification => data.map(x => new LabeledPoint((x.label * 2) - 1, x.features))
+ case _ => data
+ }
+ val initialTree = trees(0)
+ val numIterations = trees.length
+ val evaluationArray = Array.fill(numIterations)(0.0)
+
+ // Initial weight is 1.0
+ var predictionErrorModel = remappedData.map {i =>
--- End diff --
predictionErrorModel is an odd name (model?). I'd rename it to predictionAndError and possibly add an explicit type for clarity.
---
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-6025] [MLlib] Add helper method evaluat...
Posted by MechCoder <gi...@git.apache.org>.
Github user MechCoder commented on the pull request:
https://github.com/apache/spark/pull/4906#issuecomment-80651819
@jkbradley should look ok 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-6025] [MLlib] Add helper method evaluat...
Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:
https://github.com/apache/spark/pull/4906
---
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-6025] [MLlib] Add helper method evaluat...
Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:
https://github.com/apache/spark/pull/4906#issuecomment-80689341
[Test build #28611 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/28611/consoleFull) for PR 4906 at commit [`c04a430`](https://github.com/apache/spark/commit/c04a4305dc2e584affd90df2722d4ab534a67273).
* 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-6025] [MLlib] Add helper method evaluat...
Posted by jkbradley <gi...@git.apache.org>.
Github user jkbradley commented on a diff in the pull request:
https://github.com/apache/spark/pull/4906#discussion_r26439907
--- Diff: mllib/src/main/scala/org/apache/spark/mllib/tree/loss/AbsoluteError.scala ---
@@ -61,4 +61,18 @@ object AbsoluteError extends Loss {
math.abs(err)
}.mean()
}
+
+ /**
--- End diff --
Yes please
---
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-6025] [MLlib] Add helper method evaluat...
Posted by jkbradley <gi...@git.apache.org>.
Github user jkbradley commented on a diff in the pull request:
https://github.com/apache/spark/pull/4906#discussion_r26056473
--- Diff: mllib/src/main/scala/org/apache/spark/mllib/tree/GradientBoostedTrees.scala ---
@@ -69,6 +74,42 @@ class GradientBoostedTrees(private val boostingStrategy: BoostingStrategy)
case _ =>
throw new IllegalArgumentException(s"$algo is not supported by the gradient boosting.")
}
+ baseLearners = fitGradientBoostingModel.trees
+ baseLearnerWeights = fitGradientBoostingModel.treeWeights
+ fitGradientBoostingModel
+ }
+
+ /**
+ * Method to compute error or loss for every iteration of gradient boosting.
+ * @param data: RDD of [[org.apache.spark.mllib.regression.LabeledPoint]]
+ * @param loss: evaluation metric that defaults to boostingStrategy.loss
+ * @return an array with index i having the losses or errors for the ensemble
+ * containing trees 1 to i + 1
+ */
+ def evaluateEachIteration(
+ data: RDD[LabeledPoint],
+ loss: Loss = boostingStrategy.loss) : Array[Double] = {
+
+ val algo = boostingStrategy.treeStrategy.algo
+ val remappedData = algo match {
+ case Classification => data.map(x => new LabeledPoint((x.label * 2) - 1, x.features))
+ case _ => data
+ }
+ val initialTree = baseLearners(0)
+ val evaluationArray = Array.fill(numIterations)(0.0)
+
+ // Initial weight is 1.0
+ var predictionRDD = remappedData.map(i => initialTree.predict(i.features))
+ evaluationArray(0) = loss.computeError(remappedData, predictionRDD)
+
+ (1 until numIterations).map {nTree =>
--- End diff --
This does numIterations maps, broadcasting the model numIterations times. I'd recommend using a broadcast variable for the model to make sure it's only sent once.
You could keep the current approach pretty much as-is, but it does numIterations actions, so it's a bit inefficient. You could optimize it by using only 1 map, but that would require modifying the computeError method as follows:
* computeError could be overloaded to take (prediction: Double, datum: LabeledPoint). This could replace the computeError method you implemented.
* Here, in evaluateEachIteration, you could call predictionRDD.map, and within the map, for each data point, you could evaluate each tree on the data point, compute the prediction from each iteration via a cumulative sum, and then calling computeError on each prediction.
---
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-6025] [MLlib] Add helper method evaluat...
Posted by MechCoder <gi...@git.apache.org>.
Github user MechCoder commented on the pull request:
https://github.com/apache/spark/pull/4906#issuecomment-78131758
@jkbradley Fixed ! Should look better 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-6025] [MLlib] Add helper method evaluat...
Posted by jkbradley <gi...@git.apache.org>.
Github user jkbradley commented on a diff in the pull request:
https://github.com/apache/spark/pull/4906#discussion_r26539505
--- Diff: mllib/src/main/scala/org/apache/spark/mllib/tree/model/treeEnsembleModels.scala ---
@@ -108,6 +110,58 @@ class GradientBoostedTreesModel(
}
override protected def formatVersion: String = TreeEnsembleModel.SaveLoadV1_0.thisFormatVersion
+
+ /**
+ * Method to compute error or loss for every iteration of gradient boosting.
+ * @param data RDD of [[org.apache.spark.mllib.regression.LabeledPoint]]
+ * @param loss evaluation metric.
+ * @return an array with index i having the losses or errors for the ensemble
+ * containing trees 1 to i + 1
+ */
+ def evaluateEachIteration(
+ data: RDD[LabeledPoint],
+ loss: Loss): Array[Double] = {
+
+ val sc = data.sparkContext
+ val remappedData = algo match {
+ case Classification => data.map(x => new LabeledPoint((x.label * 2) - 1, x.features))
+ case _ => data
+ }
+
+ val numIterations = trees.length
+ val evaluationArray = Array.fill(numIterations)(0.0)
+
+ var predictionAndError: RDD[(Double, Double)] = remappedData.map { i =>
+ val pred = treeWeights(0) * trees(0).predict(i.features)
+ val error = loss.computeError(pred, i.label)
+ (pred, error)
+ }
+ evaluationArray(0) = predictionAndError.values.mean()
+
+ // Avoid the model being copied across numIterations.
+ val broadcastTrees = sc.broadcast(trees)
+ val broadcastWeights = sc.broadcast(treeWeights)
+
+ (1 until numIterations).map { nTree =>
+ predictionAndError = remappedData.zip(predictionAndError).mapPartitions { iter =>
+ val currentTree = broadcastTrees.value(nTree)
+ val currentTreeWeight = broadcastWeights.value(nTree)
+ iter.map {
+ case (point, (pred, error)) => {
+ val newPred = pred + currentTree.predict(point.features) * currentTreeWeight
--- End diff --
I just realized: This is correct for regression but not for classification. For classification, it should threshold as in [https://github.com/apache/spark/blob/e3f315ac358dfe4f5b9705c3eac76e8b1e24f82a/mllib/src/main/scala/org/apache/spark/mllib/tree/model/treeEnsembleModels.scala#L194]
It's also a problem that the test suite didn't find this error. Could you please first fix the test suite so that it fails because of this error and then fix it here?
Thanks! Sorry I didn't realize it 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-6025] [MLlib] Add helper method evaluat...
Posted by MechCoder <gi...@git.apache.org>.
Github user MechCoder commented on a diff in the pull request:
https://github.com/apache/spark/pull/4906#discussion_r26191896
--- Diff: mllib/src/main/scala/org/apache/spark/mllib/tree/loss/AbsoluteError.scala ---
@@ -61,4 +61,18 @@ object AbsoluteError extends Loss {
math.abs(err)
}.mean()
}
+
+ /**
--- End diff --
But the return argument is different, no?
---
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-6025] [MLlib] Add helper method evaluat...
Posted by jkbradley <gi...@git.apache.org>.
Github user jkbradley commented on a diff in the pull request:
https://github.com/apache/spark/pull/4906#discussion_r26179915
--- Diff: mllib/src/main/scala/org/apache/spark/mllib/tree/model/treeEnsembleModels.scala ---
@@ -108,6 +110,53 @@ class GradientBoostedTreesModel(
}
override protected def formatVersion: String = TreeEnsembleModel.SaveLoadV1_0.thisFormatVersion
+
+ /**
+ * Method to compute error or loss for every iteration of gradient boosting.
+ * @param data: RDD of [[org.apache.spark.mllib.regression.LabeledPoint]]
+ * @param loss: evaluation metric.
+ * @return an array with index i having the losses or errors for the ensemble
+ * containing trees 1 to i + 1
+ */
+ def evaluateEachIteration(
+ data: RDD[LabeledPoint],
+ loss: Loss) : Array[Double] = {
+
+ val sc = data.sparkContext
+ val remappedData = algo match {
+ case Classification => data.map(x => new LabeledPoint((x.label * 2) - 1, x.features))
+ case _ => data
+ }
+ val initialTree = trees(0)
+ val numIterations = trees.length
+ val evaluationArray = Array.fill(numIterations)(0.0)
+
+ // Initial weight is 1.0
+ var predictionErrorModel = remappedData.map {i =>
+ val pred = initialTree.predict(i.features)
+ val error = loss.computeError(i, pred)
+ (pred, error)
+ }
+ evaluationArray(0) = predictionErrorModel.values.mean()
+
+ // Avoid the model being copied across numIterations.
+ val broadcastTrees = sc.broadcast(trees)
+ val broadcastWeights = sc.broadcast(treeWeights)
+
+ (1 until numIterations).map {nTree =>
+ predictionErrorModel = (remappedData zip predictionErrorModel) map {
+ case (point, (pred, error)) => {
+ val newPred = pred + (
--- End diff --
style: parenthesis on next 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-6025] [MLlib] Add helper method evaluat...
Posted by jkbradley <gi...@git.apache.org>.
Github user jkbradley commented on a diff in the pull request:
https://github.com/apache/spark/pull/4906#discussion_r26883459
--- Diff: mllib/src/main/scala/org/apache/spark/mllib/tree/model/treeEnsembleModels.scala ---
@@ -108,6 +110,58 @@ class GradientBoostedTreesModel(
}
override protected def formatVersion: String = TreeEnsembleModel.SaveLoadV1_0.thisFormatVersion
+
+ /**
+ * Method to compute error or loss for every iteration of gradient boosting.
+ * @param data RDD of [[org.apache.spark.mllib.regression.LabeledPoint]]
+ * @param loss evaluation metric.
+ * @return an array with index i having the losses or errors for the ensemble
+ * containing trees 1 to i + 1
+ */
+ def evaluateEachIteration(
+ data: RDD[LabeledPoint],
+ loss: Loss): Array[Double] = {
+
+ val sc = data.sparkContext
+ val remappedData = algo match {
+ case Classification => data.map(x => new LabeledPoint((x.label * 2) - 1, x.features))
+ case _ => data
+ }
+
+ val numIterations = trees.length
+ val evaluationArray = Array.fill(numIterations)(0.0)
+
+ var predictionAndError: RDD[(Double, Double)] = remappedData.map { i =>
+ val pred = treeWeights(0) * trees(0).predict(i.features)
+ val error = loss.computeError(pred, i.label)
+ (pred, error)
+ }
+ evaluationArray(0) = predictionAndError.values.mean()
+
+ // Avoid the model being copied across numIterations.
+ val broadcastTrees = sc.broadcast(trees)
+ val broadcastWeights = sc.broadcast(treeWeights)
+
+ (1 until numIterations).map { nTree =>
+ predictionAndError = remappedData.zip(predictionAndError).mapPartitions { iter =>
+ val currentTree = broadcastTrees.value(nTree)
+ val currentTreeWeight = broadcastWeights.value(nTree)
+ iter.map {
+ case (point, (pred, error)) => {
+ val newPred = pred + currentTree.predict(point.features) * currentTreeWeight
--- End diff --
You're right; I was getting confused. It's correct to use the raw prediction for classification, as you're doing.
---
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-6025] [MLlib] Add helper method evaluat...
Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:
https://github.com/apache/spark/pull/4906#issuecomment-78227740
[Test build #28468 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/28468/consoleFull) for PR 4906 at commit [`ebbd1ad`](https://github.com/apache/spark/commit/ebbd1ad3ef1f8f1b95febdd8daac3f14c804fbad).
* This patch **fails Spark unit 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-6025] [MLlib] Add helper method evaluat...
Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:
https://github.com/apache/spark/pull/4906#issuecomment-80689362
Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/28611/
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-6025] [MLlib] Add helper method evaluat...
Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:
https://github.com/apache/spark/pull/4906#issuecomment-82184176
Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/28705/
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-6025] [MLlib] Add helper method evaluat...
Posted by jkbradley <gi...@git.apache.org>.
Github user jkbradley commented on a diff in the pull request:
https://github.com/apache/spark/pull/4906#discussion_r26056478
--- Diff: mllib/src/main/scala/org/apache/spark/mllib/tree/GradientBoostedTrees.scala ---
@@ -69,6 +74,42 @@ class GradientBoostedTrees(private val boostingStrategy: BoostingStrategy)
case _ =>
throw new IllegalArgumentException(s"$algo is not supported by the gradient boosting.")
}
+ baseLearners = fitGradientBoostingModel.trees
+ baseLearnerWeights = fitGradientBoostingModel.treeWeights
+ fitGradientBoostingModel
+ }
+
+ /**
+ * Method to compute error or loss for every iteration of gradient boosting.
+ * @param data: RDD of [[org.apache.spark.mllib.regression.LabeledPoint]]
+ * @param loss: evaluation metric that defaults to boostingStrategy.loss
+ * @return an array with index i having the losses or errors for the ensemble
+ * containing trees 1 to i + 1
+ */
+ def evaluateEachIteration(
--- End diff --
This method should be implemented in the model, not in the estimator. There's no need to make a duplicate of the model in the estimator class. (We try to keep estimator classes stateless except for parameter values so that they remain lightweight types.)
This change will require a bit of refactoring, so I'll hold off on more comments until then.
---
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-6025] [MLlib] Add helper method evaluat...
Posted by MechCoder <gi...@git.apache.org>.
Github user MechCoder commented on a diff in the pull request:
https://github.com/apache/spark/pull/4906#discussion_r26192410
--- Diff: mllib/src/main/scala/org/apache/spark/mllib/tree/loss/Loss.scala ---
@@ -49,4 +49,14 @@ trait Loss extends Serializable {
*/
def computeError(model: TreeEnsembleModel, data: RDD[LabeledPoint]): Double
--- End diff --
Great, It gives mental satisfaction on removing huge blocks of code :P
---
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-6025] [MLlib] Add helper method evaluat...
Posted by MechCoder <gi...@git.apache.org>.
Github user MechCoder commented on a diff in the pull request:
https://github.com/apache/spark/pull/4906#discussion_r26551383
--- Diff: mllib/src/main/scala/org/apache/spark/mllib/tree/model/treeEnsembleModels.scala ---
@@ -108,6 +110,58 @@ class GradientBoostedTreesModel(
}
override protected def formatVersion: String = TreeEnsembleModel.SaveLoadV1_0.thisFormatVersion
+
+ /**
+ * Method to compute error or loss for every iteration of gradient boosting.
+ * @param data RDD of [[org.apache.spark.mllib.regression.LabeledPoint]]
+ * @param loss evaluation metric.
+ * @return an array with index i having the losses or errors for the ensemble
+ * containing trees 1 to i + 1
+ */
+ def evaluateEachIteration(
+ data: RDD[LabeledPoint],
+ loss: Loss): Array[Double] = {
+
+ val sc = data.sparkContext
+ val remappedData = algo match {
+ case Classification => data.map(x => new LabeledPoint((x.label * 2) - 1, x.features))
+ case _ => data
+ }
+
+ val numIterations = trees.length
+ val evaluationArray = Array.fill(numIterations)(0.0)
+
+ var predictionAndError: RDD[(Double, Double)] = remappedData.map { i =>
+ val pred = treeWeights(0) * trees(0).predict(i.features)
+ val error = loss.computeError(pred, i.label)
+ (pred, error)
+ }
+ evaluationArray(0) = predictionAndError.values.mean()
+
+ // Avoid the model being copied across numIterations.
+ val broadcastTrees = sc.broadcast(trees)
+ val broadcastWeights = sc.broadcast(treeWeights)
+
+ (1 until numIterations).map { nTree =>
+ predictionAndError = remappedData.zip(predictionAndError).mapPartitions { iter =>
+ val currentTree = broadcastTrees.value(nTree)
+ val currentTreeWeight = broadcastWeights.value(nTree)
+ iter.map {
+ case (point, (pred, error)) => {
+ val newPred = pred + currentTree.predict(point.features) * currentTreeWeight
--- End diff --
I think this is more of a design problem. Do we want `evaluateEachIteration` to do the same thing as what the `GradientBoostingModel` does internally (since the algo is set to Regression explicitly)? I also think it might be confusing if users see that during classification problems, this method behaves in a different way as compared to internally.
---
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-6025] [MLlib] Add helper method evaluat...
Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:
https://github.com/apache/spark/pull/4906#issuecomment-80861278
[Test build #28621 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/28621/consoleFull) for PR 4906 at commit [`352001f`](https://github.com/apache/spark/commit/352001fc81912e273159580225b3db2a1cac06aa).
* 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-6025] [MLlib] Add helper method evaluat...
Posted by MechCoder <gi...@git.apache.org>.
Github user MechCoder commented on a diff in the pull request:
https://github.com/apache/spark/pull/4906#discussion_r26551479
--- Diff: mllib/src/main/scala/org/apache/spark/mllib/tree/model/treeEnsembleModels.scala ---
@@ -108,6 +110,58 @@ class GradientBoostedTreesModel(
}
override protected def formatVersion: String = TreeEnsembleModel.SaveLoadV1_0.thisFormatVersion
+
+ /**
+ * Method to compute error or loss for every iteration of gradient boosting.
+ * @param data RDD of [[org.apache.spark.mllib.regression.LabeledPoint]]
+ * @param loss evaluation metric.
+ * @return an array with index i having the losses or errors for the ensemble
+ * containing trees 1 to i + 1
+ */
+ def evaluateEachIteration(
+ data: RDD[LabeledPoint],
+ loss: Loss): Array[Double] = {
+
+ val sc = data.sparkContext
+ val remappedData = algo match {
+ case Classification => data.map(x => new LabeledPoint((x.label * 2) - 1, x.features))
+ case _ => data
+ }
+
+ val numIterations = trees.length
+ val evaluationArray = Array.fill(numIterations)(0.0)
+
+ var predictionAndError: RDD[(Double, Double)] = remappedData.map { i =>
+ val pred = treeWeights(0) * trees(0).predict(i.features)
+ val error = loss.computeError(pred, i.label)
+ (pred, error)
+ }
+ evaluationArray(0) = predictionAndError.values.mean()
+
+ // Avoid the model being copied across numIterations.
+ val broadcastTrees = sc.broadcast(trees)
+ val broadcastWeights = sc.broadcast(treeWeights)
+
+ (1 until numIterations).map { nTree =>
+ predictionAndError = remappedData.zip(predictionAndError).mapPartitions { iter =>
+ val currentTree = broadcastTrees.value(nTree)
+ val currentTreeWeight = broadcastWeights.value(nTree)
+ iter.map {
+ case (point, (pred, error)) => {
+ val newPred = pred + currentTree.predict(point.features) * currentTreeWeight
--- End diff --
And also the fact that runWithValidation breaks according to the Regression loss and not the Classification loss. I suggest we keep this as it is and maybe add a comment?
wdyt?
---
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-6025] [MLlib] Add helper method evaluat...
Posted by jkbradley <gi...@git.apache.org>.
Github user jkbradley commented on a diff in the pull request:
https://github.com/apache/spark/pull/4906#discussion_r26439846
--- Diff: mllib/src/main/scala/org/apache/spark/mllib/tree/loss/Loss.scala ---
@@ -49,4 +49,14 @@ trait Loss extends Serializable {
*/
def computeError(model: TreeEnsembleModel, data: RDD[LabeledPoint]): Double
--- End diff --
: )
---
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-6025] [MLlib] Add helper method evaluat...
Posted by jkbradley <gi...@git.apache.org>.
Github user jkbradley commented on a diff in the pull request:
https://github.com/apache/spark/pull/4906#discussion_r26179917
--- Diff: mllib/src/main/scala/org/apache/spark/mllib/tree/model/treeEnsembleModels.scala ---
@@ -108,6 +110,53 @@ class GradientBoostedTreesModel(
}
override protected def formatVersion: String = TreeEnsembleModel.SaveLoadV1_0.thisFormatVersion
+
+ /**
+ * Method to compute error or loss for every iteration of gradient boosting.
+ * @param data: RDD of [[org.apache.spark.mllib.regression.LabeledPoint]]
+ * @param loss: evaluation metric.
+ * @return an array with index i having the losses or errors for the ensemble
+ * containing trees 1 to i + 1
+ */
+ def evaluateEachIteration(
+ data: RDD[LabeledPoint],
+ loss: Loss) : Array[Double] = {
+
+ val sc = data.sparkContext
+ val remappedData = algo match {
+ case Classification => data.map(x => new LabeledPoint((x.label * 2) - 1, x.features))
+ case _ => data
+ }
+ val initialTree = trees(0)
+ val numIterations = trees.length
+ val evaluationArray = Array.fill(numIterations)(0.0)
+
+ // Initial weight is 1.0
+ var predictionErrorModel = remappedData.map {i =>
+ val pred = initialTree.predict(i.features)
+ val error = loss.computeError(i, pred)
+ (pred, error)
+ }
+ evaluationArray(0) = predictionErrorModel.values.mean()
+
+ // Avoid the model being copied across numIterations.
+ val broadcastTrees = sc.broadcast(trees)
+ val broadcastWeights = sc.broadcast(treeWeights)
+
+ (1 until numIterations).map {nTree =>
+ predictionErrorModel = (remappedData zip predictionErrorModel) map {
+ case (point, (pred, error)) => {
+ val newPred = pred + (
+ broadcastTrees.value(nTree).predict(point.features) * broadcastWeights.value(nTree))
+ val newError = loss.computeError(point, newPred)
+ (newPred, newError)
+ }
+ }
+ evaluationArray(nTree) = predictionErrorModel.values.mean()
+ }
+ evaluationArray
--- End diff --
You might want to explicitly unpersist the broadcast values before returning. They will get unpersisted once their values go out of scope, but it might take longer.
---
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-6025] [MLlib] Add helper method evaluat...
Posted by jkbradley <gi...@git.apache.org>.
Github user jkbradley commented on a diff in the pull request:
https://github.com/apache/spark/pull/4906#discussion_r26179893
--- Diff: mllib/src/main/scala/org/apache/spark/mllib/tree/loss/Loss.scala ---
@@ -49,4 +49,14 @@ trait Loss extends Serializable {
*/
def computeError(model: TreeEnsembleModel, data: RDD[LabeledPoint]): Double
+ /**
+ * Method to calculate loss when the predictions are already known.
+ * Note: This method is used in the method evaluateEachIteration to avoid recomputing the
+ * predicted values from previously fit trees.
+ * @param datum: LabeledPoint
+ * @param prediction: Predicted label.
+ * @return Measure of model error on datapoint.
+ */
+ def computeError(datum: LabeledPoint, prediction: Double) : Double
--- End diff --
switch arg order to match batch computeError more closely
no space before colon (here and elsewhere)
---
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-6025] [MLlib] Add helper method evaluat...
Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:
https://github.com/apache/spark/pull/4906#issuecomment-78233037
Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/28470/
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-6025] [MLlib] Add helper method evaluat...
Posted by jkbradley <gi...@git.apache.org>.
Github user jkbradley commented on the pull request:
https://github.com/apache/spark/pull/4906#issuecomment-82000038
It's hard to state a hard cutoff for task size, but the Spark programming guide recommends "tasks larger than about 20 KB are probably worth optimizing [by broadcasting]." I think it's reasonable 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-6025] [MLlib] Add helper method evaluat...
Posted by jkbradley <gi...@git.apache.org>.
Github user jkbradley commented on the pull request:
https://github.com/apache/spark/pull/4906#issuecomment-80628130
@MechCoder
> I have a query regarding the use of mapPartition vs map. I see that mapPartition is preferred when there is a huge overhead for each task, is that right?
Yep, that's correct.
I'll take a final look 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-6025] [MLlib] Add helper method evaluat...
Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:
https://github.com/apache/spark/pull/4906#issuecomment-78132316
[Test build #28435 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/28435/consoleFull) for PR 4906 at commit [`035f78f`](https://github.com/apache/spark/commit/035f78fa557eb9668ee7b2750fa9d3a4ac1cd395).
* 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-6025] [MLlib] Add helper method evaluat...
Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:
https://github.com/apache/spark/pull/4906#issuecomment-78147903
[Test build #28435 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/28435/consoleFull) for PR 4906 at commit [`035f78f`](https://github.com/apache/spark/commit/035f78fa557eb9668ee7b2750fa9d3a4ac1cd395).
* 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-6025] [MLlib] Add helper method evaluat...
Posted by MechCoder <gi...@git.apache.org>.
Github user MechCoder commented on a diff in the pull request:
https://github.com/apache/spark/pull/4906#discussion_r26439882
--- Diff: mllib/src/main/scala/org/apache/spark/mllib/tree/loss/AbsoluteError.scala ---
@@ -61,4 +61,18 @@ object AbsoluteError extends Loss {
math.abs(err)
}.mean()
}
+
+ /**
--- End diff --
ok so should I 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