我正在尝试通过将csv文件中的数据读入数据帧来在python中实现SVM。我已经为测试和培训拆分了数据集。我是python的新手,无法弄清楚为什么会发生此特定错误。我的代码是:
from sklearn import svm
from sklearn.model_selection import train_test_split
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
df = pd.read_csv('Employee.csv')
X = df.iloc[:, :-1].values
y = df.iloc[:, 1].values
# Create SVM classification object
model = svm.SVC(kernel='linear',C=1, gamma=1)
model.fit(X, y)
model.score(X, y)
#Predict Output
x_test= train_test_split(df, test_size=0.2)
predicted= model.predict(x_test)
错误在下面的行中:
predicted= model.predict(x_test)