python机器学习及实践(从零开始kaggle竞赛之路)第二章的2.1.2.5集成模型程序报错:numpy.core._internal.AxisError: axis 0 is out of bo
2018-02-08 10:52
666 查看
python机器学习及实践(从零开始kaggle竞赛之路)第二章的2.1.2.5集成模型程序报错:numpy.core._internal.AxisError: axis 0 is out of bounds for array of dimension 0:
1.原因是本段代码在python3以上执行时:
print(np.sort(zip(etr.feature_importances_,bosten.feature_names),axis=0))zip函数返回的是迭代器结果
在python2.7下执行是通过的
2.修改代码为:
print(np.sort(list(zip(etr.feature_importances_,bosten.feature_names)),axis=0))结果通过:
[['0.00393385852727' 'AGE']
['0.00823453398696' 'B']
['0.0137169582645' 'CHAS']
['0.0170472963716' 'CRIM']
['0.0195123294833' 'DIS']
['0.0196218058374' 'INDUS']
['0.026176925494' 'LSTAT']
['0.0285497800029' 'NOX']
['0.0294926254675' 'PTRATIO']
['0.059896715878' 'RAD']
['0.0625512807314' 'RM']
['0.334454711687' 'TAX']
['0.376811178269' 'ZN']]
1.原因是本段代码在python3以上执行时:
print(np.sort(zip(etr.feature_importances_,bosten.feature_names),axis=0))zip函数返回的是迭代器结果
在python2.7下执行是通过的
2.修改代码为:
print(np.sort(list(zip(etr.feature_importances_,bosten.feature_names)),axis=0))结果通过:
[['0.00393385852727' 'AGE']
['0.00823453398696' 'B']
['0.0137169582645' 'CHAS']
['0.0170472963716' 'CRIM']
['0.0195123294833' 'DIS']
['0.0196218058374' 'INDUS']
['0.026176925494' 'LSTAT']
['0.0285497800029' 'NOX']
['0.0294926254675' 'PTRATIO']
['0.059896715878' 'RAD']
['0.0625512807314' 'RM']
['0.334454711687' 'TAX']
['0.376811178269' 'ZN']]
相关文章推荐
- python机器学习及实践(从零开始kaggle竞赛之路)第二章的2.1.2.1线性回归器程序报错Reshape your data either using array.reshape(-1, 1)
- 机器学习中代码出现tensorflow.python.framework.errors_impl.InternalError,from device: CUDA_ERROR_OUT_OF_MEMORY
- MNC用自己的数据运行得到如下错误:IndexError: index 4 is out of bounds for axis 1 with size 4
- python-opencv:ImportError: numpy.core.multiarray failed to import
- 错误分析:Internal Query Processor Error: The query processor ran out of stack space during query optimization.
- 【GCC调试程序C语言问题】error: initializer-string for array of chars is too long [-fpermissive]
- MPI编译C++程序出现#error "SEEK_SET is #defined but must not be for the C++ binding of MPI" 的解决方法
- 解决Tomcat启动多个web项目报错nested exception is java.lang.OutOfMemoryError: PermGen space
- JAVA web调用执行python脚本程序的四种方式,回避java.lang.OutOfMemoryError:PermGen space内存溢出问题
- unity3d Fatal Error : Error: Error #1000: The system is out of memory.
- Myeclipse运行程序时,发生异常:Exception in thread ""http-bio-8080"-exec-1" java.lang.OutOfMemoryError: PermGen
- Qt 编译错误 提示TypeError: Property 'asciify' of object Core::Internal::UtilsJsExtension(0x27a9278) is not
- Python操作MySQL的一个报错:IndexError: out of range
- Tomcat nested exception is java.lang.OutOfMemoryError: PermGen space
- 运行程序是内存溢出的情况:OutOfMemoryError: PermGenspace
- 使用ant打包android程序遇到OutOfMemoryError
- TypeError: value is out of bounds
- Python 爬虫 raise self._value IndexError: list index out of range
- python PIL, 错误:IndexError: string index out of range
- Tensorflow tf.nn.in_top_k Error targets[0] is out of range