Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a67ebbe

Browse filesBrowse files
lestevemr-cgsprsergiopasra
authored
FIX Work around likely SIMD issue in tree export on 32bit OS (#29327)
Co-authored-by: Michael R. Crusoe <1330696+mr-c@users.noreply.github.com> Co-authored-by: SGard Spreemann <gspr@nonempty.org> Co-authored-by: Sergio Pascual <sergiopr@fis.ucm.es>
1 parent 69b482c commit a67ebbe
Copy full SHA for a67ebbe

File tree

Expand file treeCollapse file tree

2 files changed

+13
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+13
-1
lines changed

‎doc/whats_new/v1.5.rst

Copy file name to clipboardExpand all lines: doc/whats_new/v1.5.rst
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ Changelog
5656
grids that have estimators as parameter values.
5757
:pr:`29179` by :user:`Marco Gorelli<MarcoGorelli>`.
5858

59+
:mod:`sklearn.tree`
60+
...................
61+
62+
- |Fix| Fix an issue in :func:`tree.export_graphviz` and :func:`tree.plot_tree`
63+
that could potentially result in exception or wrong results on 32bit OSes.
64+
:pr:`` by :user:`Loïc Estève<lesteve>`.
65+
5966
:mod:`sklearn.utils`
6067
....................
6168

‎sklearn/tree/_export.py

Copy file name to clipboardExpand all lines: sklearn/tree/_export.py
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,12 @@ def get_fill_color(self, tree, node_id):
259259
self.colors["rgb"] = _color_brew(tree.n_classes[0])
260260
if tree.n_outputs != 1:
261261
# Find max and min impurities for multi-output
262-
self.colors["bounds"] = (np.min(-tree.impurity), np.max(-tree.impurity))
262+
# The next line uses -max(impurity) instead of min(-impurity)
263+
# and -min(impurity) instead of max(-impurity) on purpose, in
264+
# order to avoid what looks like an issue with SIMD on non
265+
# memory aligned arrays on 32bit OS. For more details see
266+
# https://github.com/scikit-learn/scikit-learn/issues/27506.
267+
self.colors["bounds"] = (-np.max(tree.impurity), -np.min(tree.impurity))
263268
elif tree.n_classes[0] == 1 and len(np.unique(tree.value)) != 1:
264269
# Find max and min values in leaf nodes for regression
265270
self.colors["bounds"] = (np.min(tree.value), np.max(tree.value))

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.