svm.SVC() model with either 'ovo' or 'ovr' decision functions produces the exact same accuracy

1k Views Asked by At

I want to create multiple classification models using scikit-learn's svm.SVC() function on the MNINST dataset for different parameter combinations. What I have found is that for the same parameters I get the exact same accuracies both on the training and on the test set when using either 'ovo' or 'ovr' decision functions.

The code I've written is below:

kernel='linear'
c = 0.001
decision = 'ovo'

clf = svm.SVC(kernel=kernel, C=c, gamma=gamma, decision_function_shape=decision, tol=1, random_state=random_state)
clf.fit(x_train[:1000], y_train[:1000])
print(f'Train Accuracy: {clf.score(x_train[:1000], y_train[:1000]) * 100:.2f}')
print(f'Test Accuracy for ovo: {clf.score(x_test[:1000], y_test[:1000]) * 100:.2f}')

decision = 'ovr'

clf = svm.SVC(kernel=kernel, C=c, gamma=gamma, decision_function_shape=decision, tol=1, random_state=random_state)
clf.fit(x_train[:1000], y_train[:1000])
print(f'Train Accuracy: {clf.score(x_train[:1000], y_train[:1000]) * 100:.2f}')
print(f'Test Accuracy for ovr: {clf.score(x_test[:1000], y_test[:1000]) * 100:.2f}')

The program prints:

Train Accuracy for ovo: 85.40
Test Accuracy for ovo: 73.40
Train Accuracy for ovr: 85.40
Test Accuracy for ovr: 73.40

I use 1000 samples just for this example, but the issue still persists when using the whole dataset.

Why is this happening?

0

There are 0 best solutions below