Repository navigation
[SPARK-2152][MLlib] fix bin offset in DecisionTree node aggregations (also resolves SPARK-2160) - #1316
[SPARK-2152][MLlib] fix bin offset in DecisionTree node aggregations (also resolves SPARK-2160)#1316jonsondag wants to merge 1 commit into
Conversation
|
Can one of the admins verify this patch? |
|
This was reported as https://issues.apache.org/jira/browse/SPARK-2152 (and duplicated for some reason as https://issues.apache.org/jira/browse/SPARK-2160) but the author didn't seem to make a PR. You could note this is tied to SPARK-2152 and resolves both. |
|
Thanks, I have edited the subject of this pull request and added comments in JIRA. |
|
@johnnywalleye mind adding |
|
Sure, updated. |
|
@johnnywalleye Thanks! I will review this PR and get back soon. |
|
Great, thanks! On Tue, Jul 8, 2014 at 5:56 PM, manishamde notifications@github.com wrote:
|
|
LGTM! The classic off-by-one error gets you no matter how much attention you pay. Thanks for the rigorous review. @pwendell Could we also add this to the 1.0 patch release? @johnnywalleye If possible, could you also update this PR. #886 It's on my repo on branch 'multiclass'. It's easy for me to update this but I am hoping you could review it as well since it's a non-trivial change. :-) |
|
@johnnywalleye Nevermind. I fixed the same error on the multiclass PR. |
…(also resolves SPARK-2160) Hi, this pull fixes (what I believe to be) a bug in DecisionTree.scala. In the extractLeftRightNodeAggregates function, the first set of rightNodeAgg values for Regression are set in line 792 as follows: rightNodeAgg(featureIndex)(2 * (numBins - 2)) = binData(shift + (2 * numBins - 1))) Then there is a loop that sets the rest of the values, as in line 809: rightNodeAgg(featureIndex)(2 * (numBins - 2 - splitIndex)) = binData(shift + (2 *(numBins - 2 - splitIndex))) + rightNodeAgg(featureIndex)(2 * (numBins - 1 - splitIndex)) But since splitIndex starts at 1, this ends up skipping a set of binData values. The changes here address this issue, for both the Regression and Classification cases. Author: johnnywalleye <jsondag@gmail.com> Closes #1316 from johnnywalleye/master and squashes the following commits: 73809da [johnnywalleye] fix bin offset in DecisionTree node aggregations (cherry picked from commit 1114207) Signed-off-by: Xiangrui Meng <meng@databricks.com>
|
Thanks @johnnywalleye for the fix and @manishamde for reviewing the PR! I merged it into both master and branch-1.0, but I'm not sure whether it can make into v1.0.1 . I will update the JIRA if it doesn't. Btw, I tested this patch locally but let's try calling Jenkins (sorry). |
|
Jenkins, test this please. |
|
Thanks @mengxr |
Fixes test failures introduced by #1316. For both the regression and classification cases, val stats is the InformationGainStats for the best tree split. stats.predict is the predicted value for the data, before the split is made. Since 600 of the 1,000 values generated by DecisionTreeSuite.generateCategoricalDataPoints() are 1.0 and the rest 0.0, the regression tree and classification tree both correctly predict a value of 0.6 for this data now, and the assertions have been changed to reflect that. Author: johnnywalleye <jsondag@gmail.com> Closes #1343 from johnnywalleye/decision-tree-tests and squashes the following commits: ef80603 [johnnywalleye] [SPARK-2417][MLlib] Fix DecisionTree tests
Fixes test failures introduced by #1316. For both the regression and classification cases, val stats is the InformationGainStats for the best tree split. stats.predict is the predicted value for the data, before the split is made. Since 600 of the 1,000 values generated by DecisionTreeSuite.generateCategoricalDataPoints() are 1.0 and the rest 0.0, the regression tree and classification tree both correctly predict a value of 0.6 for this data now, and the assertions have been changed to reflect that. Author: johnnywalleye <jsondag@gmail.com> Closes #1343 from johnnywalleye/decision-tree-tests and squashes the following commits: ef80603 [johnnywalleye] [SPARK-2417][MLlib] Fix DecisionTree tests (cherry picked from commit d35e3db) Signed-off-by: Xiangrui Meng <meng@databricks.com>
…(also resolves SPARK-2160) Hi, this pull fixes (what I believe to be) a bug in DecisionTree.scala. In the extractLeftRightNodeAggregates function, the first set of rightNodeAgg values for Regression are set in line 792 as follows: rightNodeAgg(featureIndex)(2 * (numBins - 2)) = binData(shift + (2 * numBins - 1))) Then there is a loop that sets the rest of the values, as in line 809: rightNodeAgg(featureIndex)(2 * (numBins - 2 - splitIndex)) = binData(shift + (2 *(numBins - 2 - splitIndex))) + rightNodeAgg(featureIndex)(2 * (numBins - 1 - splitIndex)) But since splitIndex starts at 1, this ends up skipping a set of binData values. The changes here address this issue, for both the Regression and Classification cases. Author: johnnywalleye <jsondag@gmail.com> Closes apache#1316 from johnnywalleye/master and squashes the following commits: 73809da [johnnywalleye] fix bin offset in DecisionTree node aggregations (cherry picked from commit 1114207) Signed-off-by: Xiangrui Meng <meng@databricks.com>
Fixes test failures introduced by apache#1316. For both the regression and classification cases, val stats is the InformationGainStats for the best tree split. stats.predict is the predicted value for the data, before the split is made. Since 600 of the 1,000 values generated by DecisionTreeSuite.generateCategoricalDataPoints() are 1.0 and the rest 0.0, the regression tree and classification tree both correctly predict a value of 0.6 for this data now, and the assertions have been changed to reflect that. Author: johnnywalleye <jsondag@gmail.com> Closes apache#1343 from johnnywalleye/decision-tree-tests and squashes the following commits: ef80603 [johnnywalleye] [SPARK-2417][MLlib] Fix DecisionTree tests (cherry picked from commit d35e3db) Signed-off-by: Xiangrui Meng <meng@databricks.com>
…(also resolves SPARK-2160) Hi, this pull fixes (what I believe to be) a bug in DecisionTree.scala. In the extractLeftRightNodeAggregates function, the first set of rightNodeAgg values for Regression are set in line 792 as follows: rightNodeAgg(featureIndex)(2 * (numBins - 2)) = binData(shift + (2 * numBins - 1))) Then there is a loop that sets the rest of the values, as in line 809: rightNodeAgg(featureIndex)(2 * (numBins - 2 - splitIndex)) = binData(shift + (2 *(numBins - 2 - splitIndex))) + rightNodeAgg(featureIndex)(2 * (numBins - 1 - splitIndex)) But since splitIndex starts at 1, this ends up skipping a set of binData values. The changes here address this issue, for both the Regression and Classification cases. Author: johnnywalleye <jsondag@gmail.com> Closes apache#1316 from johnnywalleye/master and squashes the following commits: 73809da [johnnywalleye] fix bin offset in DecisionTree node aggregations
Fixes test failures introduced by apache#1316. For both the regression and classification cases, val stats is the InformationGainStats for the best tree split. stats.predict is the predicted value for the data, before the split is made. Since 600 of the 1,000 values generated by DecisionTreeSuite.generateCategoricalDataPoints() are 1.0 and the rest 0.0, the regression tree and classification tree both correctly predict a value of 0.6 for this data now, and the assertions have been changed to reflect that. Author: johnnywalleye <jsondag@gmail.com> Closes apache#1343 from johnnywalleye/decision-tree-tests and squashes the following commits: ef80603 [johnnywalleye] [SPARK-2417][MLlib] Fix DecisionTree tests
…che#1320) ### What changes were proposed in this pull request? The Build's "Protobuf breaking change detection and Python CodeGen check" and "Run Spark UI tests" jobs now run only when their own files change. They ran on every pull request. - **The bug.** The precondition of `.github/workflows/build_and_test.yml` gives each job a file gate: `buf=false` unless a `.proto` or `_pb2` file changes, and `ui=false` unless `ui-test/` or a static UI resource does. Spark's own lines set `buf=true` and `ui=true` unconditionally at the end of the same branch. The gates sat above those lines, so the defaults ran after the gates and undid them. That has been true since the gates were added (apache#89), and both jobs ran on apache#1311, apache#1313 and apache#1316, the last of which changed only plan files. - **The fix.** `buf=true` and `ui=true` are now set just before the buf gate, and the later block keeps only `docs=true` and `java25=true`. The SparkR, Kubernetes and OIDC gates have no later default and are unchanged. - **A lint rule keeps the order.** A new `ci-gates` rule in `dev/varka_lint.py` reports a `x=true` at a gate's own depth, later in the same branch, after that gate's `x=false`. The pre-commit hook and the Build's lint self-test both run it. Against master's workflow it reports lines 203 and 204; against this change it reports nothing. - **Plan.** `sql/varka/plans/m8/VARKA-558.md` and PLAN.md row 558. ### Why are the changes needed? Each Build spent two runners on jobs that could not fail for the change at hand, about two minutes for the protobuf check and one for the UI suite. They run in parallel with the rest, so the cost is slots on the fork's 40 concurrent jobs, not wall time. The rule matters more than the minutes: a gate that silently does nothing looks the same as one that works. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? - `dev/varka_lint.py --selftest`: 21 cases. Two are new: a gate undone by a later default is reported, and a default set before its gate is not. - The rule reports master's two lines and nothing on this change. - Ruff 0.14.8 format and check, the YAML parse, the plan lint, the quote check and the pre-commit hook pass. - This change itself edits the workflow, which no module of `modules.py` claims, so its own Build runs Spark's whole matrix and both jobs once more. The next pull request that touches neither protobuf nor UI files shows the fix by skipping both. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Code (Opus 5.5)
Hi, this pull fixes (what I believe to be) a bug in DecisionTree.scala.
In the extractLeftRightNodeAggregates function, the first set of rightNodeAgg values for Regression are set in line 792 as follows:
rightNodeAgg(featureIndex)(2 * (numBins - 2))
= binData(shift + (2 * numBins - 1)))
Then there is a loop that sets the rest of the values, as in line 809:
rightNodeAgg(featureIndex)(2 * (numBins - 2 - splitIndex)) =
binData(shift + (2 *(numBins - 2 - splitIndex))) +
rightNodeAgg(featureIndex)(2 * (numBins - 1 - splitIndex))
But since splitIndex starts at 1, this ends up skipping a set of binData values.
The changes here address this issue, for both the Regression and Classification cases.