问题描述
我正在尝试将类型从Float64的阈值数组(来自scikit Learn的隔离林的点刺文件)转换为Float32
I am trying to convert threshold array(pickle file of isolation forest from scikit learn) of type from Float64 to Float32
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,有人对此有任何解决方法吗?
I am not getting a proper conversion to Float32. I want to convert values and their type to Float32, Did anybody have any workaround this ?
推荐答案
在生成PMML文件时会导致精度问题,所以我 在那边提出了一个错误,他们为此提供了更新的解决方案 不会在内部将其转换为Float64.
It is causing a precision issue while generating a PMML file, so i raised a bug over there and they gave an updated solution for it by not converting it in to the Float64 internally.
有关更多信息,您可以点击以下链接:精度问题
For more info, you can follow this link:Precision Issue
这篇关于将numpy数组类型和值从Float64转换为Float32的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!