1

I am trying to use different techniques to classify my data. I cleaned my dataset and then I also standardized and rescaled my input components to look for any differences. When i am trying to perform the following Support Vector Machines, i get the following error.

My code:

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 results=cross_val_score(model,x,y,cv=kfold)

ValueError: The number of classes has to be greater than one; got 1 class

Community
  • 1
  • 1

0 Answers0