8000 FIX Work around likely SIMD issue in tree export on 32bit OS (#29327) · scikit-learn/scikit-learn@a67ebbe · GitHub
[go: up one dir, main page]

Skip to content

Commit a67ebbe

Browse 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

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

doc/whats_new/v1.5.rst

Lines 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

Lines 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