【发布时间】:2017-08-05 16:27:55
【问题描述】:
在加载文本文件进行数据分析时抛出一些错误最后 2 行抛出错误
import numpy as np
f=open('decision_tree_data.txt','r')
x_train=[]
y_train=[]
for line in f:
line = np.asarray(line.split(),dtype=np.float32)
x_train.append(line[:-1])
y_train.append(line[:-1])
x_train = np.asmatrix(x_train)
y_train = np.reshape(y_train,(len(y_train),1))
【问题讨论】:
-
会抛出什么错误?
-
AttributeError: 'list' 对象没有属性 'reshape',,,,,ValueError 1 x_train = np.asmatrix(x_train)2 y_train = np.reshape(y_train,(len(y_train), 1)) except (AttributeError, TypeError): ---> return _wrapit(obj, method, *args, **kwds)ValueError: cannot reshape array of size 56 into shape (14,1)
-
请以正确的格式将错误添加到问题中,而不是在 cmets 中。
标签: python numpy machine-learning