User1190882 已帮助解决转置问题。我将针对 SKlearn 问题打开一个新线程。
columns_train = np.array([df['A'], df['B'], df['C'], df['D'], df['E'], df['F'], df['G']])
X = columns_train
Y = columns_target
X = np.transpose(X)
print np.shape(X)
print np.shape(Y)
X_train, X_test, Y_train, Y_test = train_test_split(X,Y,test_size = 0.2, random_state = 42)
clf = svm.LinearSVC()
clf.fit(X_train, Y_train)
print clf
File "C:\Python27\lib\site-packages\sklearn\utils\multiclass.py", line 172, in check_classification_targets
raise ValueError("Unknown label type: %r" % y_type)
ValueError: Unknown label type: 'continuous'
在查看其他线程后,我不确定我能做些什么来使这项工作正常进行。你能给我一些建议吗?谢谢
最佳答案
编辑问题之前回答
您正在寻找的是
X = np.transpose(X)
编辑问题后回答
当变量Y
的数据类型为浮点类型时,您会收到连续
错误。在所有分类类型的问题中,您必须将标签类型维护为int
。将变量 Y 的数据类型转换为 int
就可以正常工作了。
关于python - reshape 和转置问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46807106/