Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion doc/whats_new/v1.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,21 @@ Changelog
:pr:`123456` by :user:`Joe Bloggs <joeongithub>`.
where 123456 is the *pull request* number, not the issue number.


:mod:`sklearn.calibration`
..........................

- |Enhancement| :func:`calibration.calibration_curve` accepts a parameter
`pos_label` to specify the positive class label.
:pr:`21032` by :user:`Guillaume Lemaitre <glemaitre>`.

:mod:`sklearn.ensemble`
...........................

- |Fix| Fixed a bug that could produce a segfault in rare cases for
:class:`ensemble.HistGradientBoostingClassifier` and
:class:`ensemble.HistGradientBoostingRegressor`.
:pr:`21130` :user:`Christian Lorentzen <lorentzenchr>`.

:mod:`sklearn.linear_model`
...........................

Expand Down
26 changes: 20 additions & 6 deletions sklearn/ensemble/_hist_gradient_boosting/splitting.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -388,11 +388,25 @@ cdef class Splitter:
&left_indices_buffer[offset_in_buffers[thread_idx]],
sizeof(unsigned int) * left_counts[thread_idx]
)
memcpy(
&sample_indices[right_offset[thread_idx]],
&right_indices_buffer[offset_in_buffers[thread_idx]],
sizeof(unsigned int) * right_counts[thread_idx]
)
if right_counts[thread_idx] > 0:
# If we're splitting the rightmost node of the tree, i.e. the
# rightmost node in the partition array, and if n_threads >= 2, one
# might have right_counts[-1] = 0 and right_offset[-1] = len(sample_indices)
# leading to evaluating
#
# &sample_indices[right_offset[-1]] = &samples_indices[n_samples_at_node]
# = &partition[n_samples_in_tree]
#
# which is an out-of-bounds read access that can cause a segmentation fault.
# When boundscheck=True, removing this check produces this exception:
#
# IndexError: Out of bounds on buffer access
#
memcpy(
&sample_indices[right_offset[thread_idx]],
&right_indices_buffer[offset_in_buffers[thread_idx]],
sizeof(unsigned int) * right_counts[thread_idx]
)

return (sample_indices[:right_child_position],
sample_indices[right_child_position:],
Expand Down Expand Up @@ -839,7 +853,7 @@ cdef class Splitter:
# other category. The low-support categories will always be mapped to
# the right child. We scan the sorted categories array from left to
# right and from right to left, and we stop at the middle.

# Considering ordered categories A B C D, with E being a low-support
# category: A B C D
# ^
Expand Down