我正在尝试使用不同的技术对数据进行分类。我清理了数据集,然后也对输入组件进行了标准化和缩放,以查找任何差异。当我尝试执行以下支持向量机时,出现以下错误。
我的代码:
def svm(x,x_std,x_minmax,y):
##Support Vector Machines, seeks a line that separates two classes. The
##data instances that are closest to the line are called support vectors
res_w1 = pd.DataFrame()
res_w2 = pd.DataFrame()
res_w3 = pd.DataFrame()
#model and regression
kfold = KFold(n_splits=10,random_state=7)
model = SVC(gamma='scale')
#reesults for original
#results for original input component
results=cross_val_score(model,x,y,cv=kfold)
print(f'Support Vector Machines - Accuracy {results.mean()*100:.3f}% std {results.std()*100:3f}')
#results for the standarized input components
results_std=cross_val_score(model,x_std,y,cv=kfold)
print(f'Support Vector Machines (-1..1) - Accuaracy {results_std.mean()*100:.3f})% std {results_std.std()*100:3f}')
#results for the rescaled input components
results_minmax = cross_val_score(model,x_minmax,y,cv=kfold)
print(f'Support Vector Machines (0..1) - Accuaracy {results_minmax.mean()*100:.3f})% std {results_minmax.std()*100:3f}')
res_w1['Res']=results
res_w1['Type']='SVM'
res_w2['Res']=results_std
res_w2['Type']='SVM -1..1'
res_w3['Res']=results
res_w3['Type']='SVM 0..1'
resall5=pd.concat([resall,res_w1,res_w2,res_w3], ignore_index=True)
return
-> 207个结果= cross_val_score(model,x,y,cv = kfold)
ValueError:类的数量必须大于一;一堂课