[英]Python sklearn bad input shape
i've already check the other solutions for this problem and could not find an answer. 我已经检查了这个问题的其他解决方案,找不到答案。 I was working on sklearn library with Python, but i have an error that: 我当时正在使用Python编写sklearn库,但出现一个错误:
ValueError: bad input shape (1460, 80) ValueError:输入形状错误(1460,80)
Here is my code: 这是我的代码:
import pandas as pd
from sklearn.preprocessing import LabelEncoder
data = pd.read_csv("train.csv")
x,y = data.drop(['SalePrice'], axis=1), data['SalePrice']
le = LabelEncoder()
le.fit(x)
How can i solve it? 我该如何解决? Sorry im kinda newbie on this, thanks for your help 对不起,我有点新手,谢谢您的帮助
EDIT1 编辑1
Here is the full code of error: 这是完整的错误代码:
> Traceback (most recent call last): File "houseai.py", line 11, in
> <module>
> le.fit(x) File "C:\Users\UTKU\AppData\Local\Programs\Python\Python37\lib\site-packages\sklearn\preprocessing\label.py",
> line 219, in fit
> y = column_or_1d(y, warn=True) File "C:\Users\UTKU\AppData\Local\Programs\Python\Python37\lib\site-packages\sklearn\utils\validation.py",
> line 760, in column_or_1d
> raise ValueError("bad input shape {0}".format(shape)) ValueError: bad input shape (1460, 80)
It might be possible you have some null values in the data['SalePrice'] or in the floating data, check the null values using 可能在data ['SalePrice']或浮动数据中有一些空值,请使用
bool_series = pd.notnull(data['SalePrice'])
# displayed data only with team = NaN
data[bool_series]
Check the shape of x and y 检查x和y的形状
x.shape
y.shape
if you still have the same issue then update then sample data 如果您仍然遇到相同的问题,请先更新然后再采样数据
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.