这里我找到我的问题是:

使用的是一个新的scikit学习版本,它抛出了一个错误,因为在新版本中,所有东西都必须是一个二维矩阵,甚至是一个列或行。

它甚至说:用数组来重塑你的数据。如果您的数据有一个单独的特性或数组,那么重构(-1,1)。重构(1,-1)如果它包含一个单一的样本

这是在git上面看到的一个国际友人的解答。

原文,如下:

I think you're using a new scikit-learn version and it's throwing an error because in the new version everything has to be a 2d matrix, even a single column or row.

It even says: 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.

Have you tried this on your y column?

我遇到的就是这个问题,因为我使用的sklearn 是anaconda的3.5版本,应该是最新版本,所以出现了这个问题吧

然后我们来看看解决问题的方法:

调用 xx.reshape(1,-1)

可以使用,本人亲测

即可将其转为二维数组

各位加油!

有人问起怎么调用了,这里我说下  ,直接用需要修改的 数组名.reshape(1,-1) 即可

python 使用sk_learn 遇到 问题ValueError: Expected 2D array, got 1D array instead:的更多相关文章

  1. 决策树python建模中的坑 :ValueError: Expected 2D array, got 1D array instead:

    决策树python建模中的坑 代码 #coding=utf-8 from sklearn.feature_extraction import DictVectorizerimport csvfrom ...

  2. sklearn中报错ValueError: Expected 2D array, got 1D array instead:

    from sklearn.linear_model import LinearRegression lr = LinearRegression() print(tr_x.shape,tr_y.shap ...

  3. [已解决]报错:ValueError: Expected 2D array, got scalar array instead

    报错代码: new_x = 84610 pre_y = model.predict(new_x) print(pre_y) 报错结果: ValueError: Expected 2D array, g ...

  4. pytorch报错:ValueError: Expected more than 1 value per channel when training, got input size torch.Size([1,512,1,1])

    1.pytorch报错:ValueError: Expected more than 1 value per channel when training, got input size torch.S ...

  5. odoo开发笔记--ValueError Expected singleton

    异常处理参考:https://stackoverflow.com/questions/31070640/valueerror-expected-singleton-odoo8 报错: ValueErr ...

  6. 解决Tensorflow ValueError: Failed to convert a NumPy array to a Tensor (Unsupported object type numpy.ndarray)

    问题描述 在将一个数组送入tensorflow训练时,报错如下: ValueError: Failed to convert a NumPy array to a Tensor (Unsupporte ...

  7. 【Python】【内置函数】【bytes&bytearray&str&array】

    [bytes] 英文文档: class bytes([source[, encoding[, errors]]]) Return a new “bytes” object, which is an i ...

  8. 笨方法学python中执行argv提示ValueError: not enough values to unpack (expected 4, got 1)

    解决方法:选择Terminal中输入执行ex13.py 1 2 3 执行结果如下图

  9. python写入文本报错TypeError: expected a string or other character buffer object

    今天用python写入文本, file_object2 = open('result.txt', 'w') file_object2.write(bookid_list) file_object2.c ...

随机推荐

  1. C# Json格式

    using LitJson; //自定义Json类 JsonDataResult jsondata = new JsonDataResult() { Success = false }; HttpCo ...

  2. python中多重继承与获取对象

    1.python中多重继承 除了从一个父类继承外,Python允许从多个父类继承,称为多重继承. 多重继承的继承链就不是一棵树了,它像这样: class A(object): def __init__ ...

  3. Refseq,accssion #,gi ,Ensembl的关系

    accession编号的分子类型代号: Ensembl是2000年就开始开发的基因组自动注释软件,起初是只对真核生物基因组,2009年后开始对植物,细菌等开放.既然要注释,就要有注释对象(基因,转录本 ...

  4. 20145217《信网络对抗》逆向与BOF基础实践

    20145217<信网络对抗>逆向与BOF基础实践 内容: 一.简单机器指令,汇编语言 1.'objdump -d xxx|more'反汇编命令查看机器代码,'cat'显示文件内容,'xx ...

  5. 关于Simplicity Studio使用math.h编译出错

    原因是未调用C标准库. 解决方法: 1.点项目右键——>properties——>C/C++Build——>Settings——>GNU ARM C Linker——>L ...

  6. 【Java并发】Executor框架

      Executor框架简介 Java的线程既是工作单元,也是执行机制.从JDK5开始,把工作单元和执行机制分离开来. Executor框架由3大部分组成 任务. 被执行任务需要实现的接口:Runna ...

  7. 为JAXB和response设置编码,解决wechat4j中文乱码

    如果有哪一个做程序员的小伙伴说自己没有遇到中文乱码问题,我是不愿意相信的.今天在做微信订阅号的智能回复时,又一时迷乱的跳进了中文乱码这个火坑.刚解决问题时,都欢呼雀跃了,完全忘记了她曾经带给我的痛苦. ...

  8. Linux7关闭防火墙

    RedHat Enterprise Linux 7关闭防火墙方法 在之前的版本中关闭防火墙等服务的命令是 service iptables stop /etc/init.d/iptables stop ...

  9. Dangling Javadoc comment

    Javadoc主要用于对类和方法的注释.Javadoc没有@file和@date的注解.Javadoc has no @file or @date tags. You should be taggin ...

  10. php源码之appveyor

    打开appveyor目录 是4个bat文件 1. .bat是什么? bat文件是dos下的批处理文件.批处理文件是无格式的文本文件,它包含一条或多条命令. 它的文件扩展名为.bat或.cmd 在命令提 ...