Github user facaiy commented on the issue: https://github.com/apache/spark/pull/17556 Hi, I has checked R GBM's code and found that: R's gbm uses mean value $(x + y) / 2$, not weighted mean $(c_x * x + c_y * y) / (c_x + c_y)$ described in [JIRA SPARK-16957](https://issues.apache.org/jira/browse/SPARK-16957), for split point. 1. code snippet: [gbm-developers/gbm](https://github.com/gbm-developers/gbm) commit a1defa382a629f8b97bf9f552dcd821ee7ac9dac src/node_search.cpp:145: ```c++ else if(cCurrentVarClasses == 0) // variable is continuous { // Evaluate the current split dCurrentSplitValue = 0.5*(dLastXValue + dX); } ``` 2. test To verify it, I create a toy dataset and take a test on R. ```R > f = c(0.0, 0.0, 1.0, 1.0, 1.0, 1.0) > l = c(0, 0, 1, 1, 1, 1) > df = data.frame(l, f) > sapply(df, class) l f "numeric" "numeric" > mod <- gbm(l~f, data=df, n.trees=1, bag.fraction=1, n.minobsinnode=1, distribution = "bernoulli") > pretty.gbm.tree(mod) SplitVar SplitCodePred LeftNode RightNode MissingNode ErrorReduction Weight 0 0 5.000000e-01 1 2 3 1.333333 6 1 -1 -3.000000e-03 -1 -1 -1 0.000000 2 2 -1 1.500000e-03 -1 -1 -1 0.000000 4 3 -1 1.480297e-19 -1 -1 -1 0.000000 6 Prediction 0 1.480297e-19 1 -3.000000e-03 2 1.500000e-03 3 1.480297e-19 ``` As expected, the root's split point is 5.000000e-01, namely mean value `0.5 = (0 + 1) / 2`, not weighted mean `0.66667 = (0 * 2 + 1 * 4) / 6`. 3. conclusion I prefer to using weighted mean for split point in the PR, rather than mean value in R's gbm package. How about you? @sethah @srowen
--- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org