是否可以在 scikit-learn 决策树中设置拆分值的精度?

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

访问决策树中的节点tree_.threshold时,类型似乎是float。有没有办法将阈值的 "precision" 设置为整数? 在我的例子中,特征都是整数值,因此不需要拆分以这种精度定义的值。

不,scikit-learn 树在编译时使用 double 类型作为阈值(参见 https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/tree/_tree.pyx)。固定数据类型允许生成高效的 C 代码。您将必须更改 scikit-learn 源代码,从 Cython .pyx 文件重建 C 扩展,然后安装修改后的 scikit-learn 以使用整数阈值。