user6903745
user6903745

Reputation: 5527

Is it possible to set the precision of the split values in scikit-learn decision trees?

When accessing tree_.threshold of a node in a decision tree, the type seems to be float. Is there a way to set the "precision" of the thresholds to ints? In my case, the features are all integer values so there is no need to split on values defined with such precision.

Upvotes: 1

Views: 455

Answers (1)

Mikhail Korobov
Mikhail Korobov

Reputation: 22248

No, scikit-learn trees use double type at compile time for thresholds (see https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/tree/_tree.pyx). A fixed data type allows to generate efficient C code. You will have to change scikit-learn source code, rebuild C extension from Cython .pyx files and then install your modified scikit-learn to use integer thresholds.

Upvotes: 2

Related Questions