-
-
Notifications
You must be signed in to change notification settings - Fork 26k
FIX handle properly missing value in MSE and Friedman-MSE children_impurity
#28327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
8a28e68
4cf7bef
02fd866
2ecdffe
0fc8f58
f2a7364
a4b2f43
442968b
6f070c2
4782b8a
cfb3ad7
284a450
13ddf83
e1fe9be
536dc83
a11ed82
a9c1a5b
8bede90
55e96af
a23e8aa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1150,6 +1150,11 @@ cdef class MSE(RegressionCriterion): | |
cdef intp_t k | ||
cdef float64_t w = 1.0 | ||
|
||
# The missing samples are assumed to be in | ||
# self.sample_indices[-self.n_missing:] that is | ||
# self.sample_indices[end_non_missing:self.end]. | ||
cdef intp_t end_non_missing = self.end - self.n_missing | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's move this part inside the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can also remove the comment There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We cannot define a cdef inside an if statement in Cython. Removed the comment tho. |
||
|
||
for p in range(start, pos): | ||
i = sample_indices[p] | ||
|
||
|
@@ -1160,6 +1165,19 @@ cdef class MSE(RegressionCriterion): | |
y_ik = self.y[i, k] | ||
sq_sum_left += w * y_ik * y_ik | ||
|
||
# Account for missing values that may be on the left node. | ||
# If so, then these samples are still not included in the | ||
# sq_sum_left because they are in samples[end_non_missing:end]. | ||
if self.missing_go_to_left: | ||
adam2392 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
for p in range(end_non_missing, self.end): | ||
i = sample_indices[p] | ||
if sample_weight is not None: | ||
w = sample_weight[i] | ||
|
||
for k in range(self.n_outputs): | ||
y_ik = self.y[i, k] | ||
sq_sum_left += w * y_ik * y_ik | ||
|
||
sq_sum_right = self.sq_sum_total - sq_sum_left | ||
|
||
impurity_left[0] = sq_sum_left / self.weighted_n_left | ||
|
Uh oh!
There was an error while loading. Please reload this page.