ValueError: Masked arrays must be 1-D
来源:互联网 发布:国家网络质量管理 编辑:程序博客网 时间:2024/05/21 10:23
问题说明
使用numpy画散点图出现以上问题。(《机器学习-算法原理与编程实践》第7页)
原代码如下:
import numpy as npimport matplotlib.pyplot as pltdataSet=np.random.rand(2,10)dataSet=np.mat(dataSet)#1print(dataSet)plt.scatter(dataSet[0],dataSet[1])#2plt.show()
解决方案
方法很多,如
1. 去掉#1处代码(似乎等于没说)
2. #2改为plt.scatter(dataSet[0].tolist(),dataSet[1].tolist())
或plt.scatter(array(dataSet[0]),array(dataSet[1].tolist()))
type(dataSet[0])==<class 'numpy.matrixlib.defmatrix.matrix'>是矩阵对象不是一维(1-D)的
阅读全文
0 0
- ValueError: Masked arrays must be 1-D
- 机器学习实战第九章ValueError: Masked arrays must be 1-D
- tensorflow ValueError: Dimensions must be equal
- ValueError: fill value must be in categories.
- ValueError: IV must be 16 bytes long问题的解决
- ValueError:Cannot assign:A must be a 'B' instance.
- Python Error1: ValueError: range parameter must be finite.
- ValueError: Shape must be rank 0 but is rank 1 for 'train_data/ReadFile' (op: 'ReadFile') with input
- 使用 python 的sklearn模块,训练模型时,出现 ValueError: min_samples_split must be at least 2 or in (0, 1], got 1 的
- python reshape()函数ValueError: total size of new array must be unchanged
- Keras VGG16中ValueError: filter must not be larger than the input问题的解决
- Faster R-CNN, ValueError, total size of new array must be unchanged
- python 报ValueError: Bin labels must be one fewer than the number of bin edges
- Python TypeError: return arrays must be of ArrayType
- python中关于Np.hstack()错误的ValueError: all the input arrays must have same number of dimensions
- ValueError: Expected 2D array, got 1D array instead:
- 手把手教你 python读取文件报错:ValueError encoding must be one of 'utf_8', 'big5', or 'gbk'.
- 机器学习实战 决策树代码 计算香农熵 Error return arrays must be of ArrayType
- JavaScript/HTML的压缩和转义
- ORM
- 【知识整理】Node.js-Koa之Web App的功能
- redis下rdb在不同服务器之间的迁移 导入阿里云redis
- Ubuntu16.04下安装mysql 5.7.20
- ValueError: Masked arrays must be 1-D
- 【LeetCode】118. Pascal's Triangle
- Floyed算法求最短路径及其长度矩阵和路径矩阵
- Leetcode 算法习题 第十四周
- linux学习笔记--(01)ubuntu sudo update与upgrade的作用及区别
- 对自定义View的进一步加深
- spi 结构体清单
- js 日期排序( 使用Sort)
- mysql数据导入Hadoop之Sqoop安装