Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/277.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 重塑和转换问题_Python_Numpy_Scikit Learn - Fatal编程技术网

Python 重塑和转换问题

Python 重塑和转换问题,python,numpy,scikit-learn,Python,Numpy,Scikit Learn,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_tra

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
的数据类型为浮点类型时,会出现
continuous
错误。在所有分类类型的问题中,必须将标签类型保持为
int
。将变量Y的数据类型转换为
int
,然后它应该可以正常工作。

我编辑了这个问题,因为这里还有另一个问题,因为这个问题由多个问题组成。添加了新问题的解决方案。请不要以您发布新问题的方式编辑问题。如果您想发布新问题,请将其附加到已发布的问题中,或者发布新问题,但请不要覆盖它。是的,我考虑过,我所做的不正确,因为这会让人困惑,我现在将重新创建另一个问题,而不是其他问题,谢谢您的建议