ERROR: Found input variables with inconsistent numbers of samples: [rows, columns]

北慕城南 提交于 2020-07-10 10:27:11

问题


I don't know what to do. I want to print out the classifier score but its not working. Can someone Help me? I really don't know what is the problem maybe its something with the Numpy Array (numpy.arrange).

Traceback (most recent call last):
  File "C:/Users/Maximilian.Grinik/PycharmProjects/Augenbewegung/main.py", line 27, in <module>
    xG_train,xG_test,yG_train,yG_test = train_test_split(xG,yG,test_size=0.33)
  File "C:\Users\Maximilian.Grinik\PycharmProjects\Augenbewegung\lib\site-packages\sklearn\model_selection\_split.py", line 2127, in train_test_split
    arrays = indexable(*arrays)
  File "C:\Users\Maximilian.Grinik\PycharmProjects\Augenbewegung\lib\site-packages\sklearn\utils\validation.py", line 293, in indexable
  check_consistent_length(*result)
  File "C:\Users\Maximilian.Grinik\PycharmProjects\Augenbewegung\lib\site-packages\sklearn\utils\validation.py", line 256, in check_consistent_length
    raise ValueError("Found input variables with inconsistent numbers of"
ValueError: Found input variables with inconsistent numbers of samples: [7, 10000]

import pandas as pd

from matplotlib import colors
from matplotlib import pyplot

import numpy as np

from sklearn import neighbors
from sklearn.svm import SVC

from sklearn.model_selection import train_test_split

gesundeMenschen = pd.read_csv('data/control_file.csv', sep=',', header=None)
gesundeMenschen.columns= [np.arange(10000)]
krankeMenschen = pd.read_csv('data/patient_file.csv', sep=',', header=None)
krankeMenschen.columns= [np.arange(10000)]

gesundeMenschen.loc[7] = 0
krankeMenschen.loc[7] = 1

xG = gesundeMenschen.loc[[0,1,2,3,4,5,6]]
yG = gesundeMenschen.loc[7]

xK = krankeMenschen.loc[[0,1,2,3,4,5,6]]
yK = krankeMenschen.loc[7]

xG_train,xG_test,yG_train,yG_test = train_test_split(xG,yG,test_size=0.33)

cls = SVC()
cls.fit(xG_train,yG_train)

print(cls.score(xG_test,yG_test))

来源:https://stackoverflow.com/questions/62810487/error-found-input-variables-with-inconsistent-numbers-of-samples-rows-column

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!