Skip to content

Fix random forest import with scikit-learn 1.9#1313

Open
Aplietexe wants to merge 1 commit into
automl:developmentfrom
Aplietexe:fix/sklearn-1.9-dtype
Open

Fix random forest import with scikit-learn 1.9#1313
Aplietexe wants to merge 1 commit into
automl:developmentfrom
Aplietexe:fix/sklearn-1.9-dtype

Conversation

@Aplietexe

Copy link
Copy Markdown

Reference Issues/PRs

See scikit-learn/scikit-learn#33948.
Related downstream report: automl/mighty_dr_example#1.

Description, Motivation and Context

scikit-learn 1.9 removed the private sklearn.tree._tree.DTYPE alias. SMAC's sklearn-based random forest currently imports that private symbol, so importing SMAC fails with scikit-learn 1.9:

ImportError: cannot import name 'DTYPE' from 'sklearn.tree._tree'

scikit-learn replaced this internal alias with direct np.float32 usage, so this PR does the same in SMAC.

Changes

  • Remove the private from sklearn.tree._tree import DTYPE import.
  • Use np.float32 directly when validating random forest prediction input.

Type Of Changes

What types of changes does your code introduce? Put an x in all the boxes that apply:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

What is Missing?

Nothing known.

Checklist

Go over all the following points, and put an x in all the boxes that apply.
Should there be a good argument to differ, please provide a reasoned explanation.

  • My change is based on the latest stage of the develop branch.
  • My change required a change of the documentation, which has been done.
  • I checked that the documentation can be build, visualizes everything as expected, and does not contain any warnings.
  • I have added/adapted tests to cover my changes.
  • The tests can be executed successfully.
  • I have added a description of the changes to CHANGELOG.rst.

Any other comments?

None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants