Reputation: 5527
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
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