【发布时间】:2018-02-07 20:37:36
【问题描述】:
我正在尝试将类型从 Float64 转换为 Float32 的阈值数组(来自 scikit learn 的隔离林的泡菜文件)
for i in range(len(tree.tree_.threshold)):
tree.tree_.threshold[i] = tree.tree_.threshold[i].astype(np.float32)
然后打印出来
for value in tree.tree_.threshold[:5]:
print(type(value))
print(value)
我得到的输出是:
<class 'numpy.float64'>
526226.0
<class 'numpy.float64'>
91.9514312744
<class 'numpy.float64'>
3.60330319405
<class 'numpy.float64'>
-2.0
<class 'numpy.float64'>
-2.0
我没有正确转换为 Float32。我想将值及其类型转换为 Float32,有人有解决方法吗?
【问题讨论】:
-
不,没有缺失值,最大值为526225.98822
-
你能给我们打印 tree.tree_.threshold.flags
-
C_CONTIGUOUS : False F_CONTIGUOUS : False OWNDATA : False WRITEABLE : True ALIGNED : True UPDATEIFCOPY : False
标签: python numpy scikit-learn pickle