[已解决]报错:ValueError: Expected 2D array, got scalar array instead
报错代码:
new_x = 84610
pre_y = model.predict(new_x)
print(pre_y)
报错结果:
ValueError: Expected 2D array, got scalar array instead:
array=84610.
Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample.
解决思路:
值错误:应为二维数组,而得到的是一维数组:
使用array重新调整数据的形状。如果数据有单个功能或数组,则重新调整形状(-1,1)。如果数据包含单个示例,则重新调整形状(1,-1)。
解决方案:
加上
new_x = np.array(new_x).reshape(1, -1)
修改后的代码:
new_x = 84610
new_x = np.array(new_x).reshape(1, -1)
pre_y = model.predict(new_x)
print(pre_y)
[已解决]报错:ValueError: Expected 2D array, got scalar array instead的更多相关文章
- sklearn中报错ValueError: Expected 2D array, got 1D array instead:
from sklearn.linear_model import LinearRegression lr = LinearRegression() print(tr_x.shape,tr_y.shap ...
- [已解决]报错:xlrd.compdoc.CompDocError: Workbook: size exceeds expected 17920 bytes; corrupt?
报错代码如下: filePath='test.xls' data=pd.read_excel(filePath) print(data.head()) 报错内容如下: Traceback (most ...
- [已解决]报错: Error response from daemon: conflict
报错内容: Error response from daemon: conflict: unable to delete f5b6ef70d79b (must be forced) - image i ...
- [已解决]报错: Windows下Redis服务无法启动,错误 1067 进程意外终止解决方案
启动redis时出现的报错内容: 解决方法: 找到登录状态 如果是网络服务,直接双击此服务,修改为本地系统服务即可启动!
- [已解决]报错: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/Users/mac/Ana
报错代码: pip3 install gerapy 报错内容: Could not install packages due to an EnvironmentError: [Errno 13] Pe ...
- [已解决]报错: Creating Server TCP listening socket 127.0.0.1:6379: bind: No error
问题: windows下安装Redis第一次启动报错: [2368] 21 Apr 02:57:05.611 # Creating Server TCP listening socket 127.0. ...
- [已解决]报错JSONDecodeError
报错: 解决:
- [已解决]报错:have mixed types. Specify dtype option on import or set low_memory=False
报错代码: import pandas as pd pd1 = pd.read_csv('D:/python34/program/wx_chat_single/qq_single.csv') 报错内容 ...
- [已解决]报错Could not install packages due to an EnvironmentError
安装OpenCV过程中出现错误 代码: pip-conda install -i https://pypi.douban.com/simple/ opencv-python 报错内容如下: Could ...
随机推荐
- DPL, CPL及RPL之间的关系
DPL: Descriptor Privilege Level 1) GDT/LDT表中的描述符 GDT/LDT表中的描述符,描述的是一段内存. 其中的DPL代表着GDT/LDT中的描述符描述的内存段 ...
- ZJUT11 多校赛补题记录
牛客第一场 (通过)Integration (https://ac.nowcoder.com/acm/contest/881/B) (未补)Euclidean Distance (https://ac ...
- log4j日志格式化
Apache log4j 提供了各种布局对象,每一个对象都可以根据各种布局格式记录数据.另外,也可以创建一个布局对象格式化测井数据中的特定应用的方法. 所有的布局对象 - Appender对象收到 L ...
- Windows10下运行Android Studio3.3时关于AMD处理器不支持Intel硬件加速的解决办法
我的电脑是Thinkpad E485系列,CPU是AMD Ryzen 5 2500U,电脑预装系统是Windows10 X64家庭版,如下图所示: 下载安装了Android Studio3.3,创建了 ...
- 三、函数 (SUM、MIN、MAX、COUNT、AVG)
第八章 使用数据处理函数 8.1 函数 SQL支持利用函数来处理数据.函数一般是在数据上执行的,给数据的转换和处理提供了方便. 每一个DBMS都有特定的函数.只有少数几个函数被所有主要的DBMS等同的 ...
- MES training
unique identity 1.project name , namespace 2. select XML (not html) 3. view and controller will be i ...
- aiohttp上报405: Method Not Allowed
请求方式不对,修改为“POST”或者“GET” 可参考:https://blog.csdn.net/yiifaa/article/details/80928487
- CXF异常:No operation was found with the name
https://blog.csdn.net/qq_18675693/article/details/52134805 不同包下面,别忘了namespace最后要加“/”
- openses机制
openses 大体结构解读 页面html与相关php文件的定位 点击界面,查看出现的url 例如: http://localhost/opensns/index.php?s=/people/inde ...
- InnoDB global status
常见参数 Innodb_buffer_pool_pages_free 发现 Innodb_buffer_pool_pages_free 为0 ,则说明buffer_pool 已经被用光,需要增大 in ...