Python 错误:找到样本数不一致的输入变量:[49400,1]

Python 错误:找到样本数不一致的输入变量:[49400,1],python,scikit-learn,Python,Scikit Learn,这是我的密码 from pandas import read_csv from sklearn.model_selection import train_test_split from sklearn.svm import SVC import pandas as pd #Load dataset df = pd.read_csv(r"C:\Users\dhava\OneDrive\Documents\Folder to run environment for Anaconda\Po

这是我的密码

from pandas import read_csv
from sklearn.model_selection import train_test_split
from sklearn.svm import SVC
import pandas as pd

#Load dataset
df = pd.read_csv(r"C:\Users\dhava\OneDrive\Documents\Folder to run environment for Anaconda\Poseidon\Pump_Dataset.csv")
print(df.columns)
输出文件包含FLOWING列

Index(['id', 'target_status', 'amount_tsh', 'date_recorded', 'funder',
       'gps_height', 'installer', 'longitude', 'latitude', 'wpt_name',
       'num_private', 'basin', 'subvillage', 'region', 'region_code',
       'district_code', 'lga', 'ward', 'population', 'public_meeting',
       'recorded_by', 'scheme_management', 'scheme_name', 'permit',
       'construction_year', 'extraction_type', 'extraction_type_group',
       'extraction_type_class', 'management', 'management_group', 'payment',
       'payment_type', 'water_quality', 'quality_group', 'quantity',
       'quantity_group', 'source', 'source_type', 'source_class',
       'waterpoint_type', 'waterpoint_type_group'],
      dtype='object')
当我尝试运行下面的代码时,我遇到了上面提到的错误

inputs= df[['id', 'amount_tsh', 'date_recorded', 'funder',
       'gps_height', 'installer', 'longitude', 'latitude', 'wpt_name',
       'num_private', 'basin', 'subvillage', 'region', 'region_code',
       'district_code', 'lga', 'ward', 'population', 'public_meeting',
       'recorded_by', 'scheme_management', 'scheme_name', 'permit',
       'construction_year', 'extraction_type', 'extraction_type_group',
       'extraction_type_class', 'management', 'management_group', 'payment',
       'payment_type', 'water_quality', 'quality_group', 'quantity',
       'quantity_group', 'source', 'source_type', 'source_class',
       'waterpoint_type', 'waterpoint_type_group']]

outputs = [['target_status']]

X_train, X_test, Y_train, Y_test = train_test_split(inputs, outputs, test_size=0.20, random_state=1)

我看到输入和输出都有相同的维度

,下次请花一分钟时间看看如何正确格式化代码片段(这次为您完成)。这只是一个打字错误,您错过了此行中的
df
outputs=df['target\u status']