输入变量的样本数不一致

时间:2019-06-09 02:56:03

标签: python pandas jupyter-notebook

from sklearn.tree import DecisionTreeClassifier
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score
combine_data = pd.read_csv('combine_data.csv')
combine_data
combine_data = combine_data.drop(columns=['Ht','Wt','Player','Pos','Year','Pfr_ID', 'AV', 'Team','Round'])
combine_data = combine_data.dropna(subset=['Forty','Vertical','BenchReps','BroadJump','Cone','Shuttle','Pick'])
combine_data_X = combine_data.drop(columns=['Pick'])
combine_data_X
X = combine_data_X
y = combine_data['Pick']

X_train, X_test, y_train, y_test = train_test_split(X,y,test_size =0.2)
model = DecisionTreeClassifier()
model.fit(X_train,y_train)
predictions = model.predict([[4.2,40,40,120,4.5,2.3]])
predictions
score = accuracy_score(y_test, predictions)
score

我尝试重塑X和y变量,但得到相同的错误。

ValueError                    Traceback (most recent call last)
<ipython-input-121-a530c0d4a08a> in <module>
     29 predictions
     30 
---> 31 score = accuracy_score(y_test, predictions)
     32 score
ValueError: Found input variables with inconsistent numbers of samples: [365, 1]

如何解决此错误?我认为这是测试集的尺寸大小,但我不确定

0 个答案:

没有答案