gpt4 book ai didi

python - 找到样本数量不一致的输入变量: [rows, columns]

转载 作者:行者123 更新时间:2023-12-02 10:56:24 25 4
gpt4 key购买 nike

我不知道该怎么办。我想打印出分类器分数,但是它不起作用。有人能帮我吗?我真的不知道问题是什么,也许与Numpy Array(numpy.arrange)有关。

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))

最佳答案

文件“C:/Users//main.py”,第27行
xG_train,xG_test,yG_train,yG_test = train_test_split(xG,yG,test_size = 0.33)
在train_test_split中,文件“C:\ Users \ lib \ site-packages \ sklearn \ model_selection_split.py”第2127行
数组=可索引的(* arrays)
文件“C:\ Users \ lib \ site-packages \ sklearn \ utils \ validation.py”,第293行,可索引
check_consistent_length(*结果)
文件“C:\ Users \ lib \ site-packages \ sklearn \ utils \ validation.py”,行256,在check_consistent_length中
引发ValueError(“找到数量不一致的输入变量”
ValueError:找到输入样本数量不一致的输入变量:[7,10000]

关于python - 找到样本数量不一致的输入变量: [rows, columns],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62755345/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com