0
$\begingroup$

I have made an svm.LinearSVC model to classify images. Firstly, the features of the images are extracted by SIFT and then based on them the LinearSVC is trained. I have the following Python snippet:

from sklearn import svm

model = svm.LinearSVC(C=2, max_iter=10000)

model(x_train, y_train.ravel())

y_pred = model(x_test)

print(metrics.accuracy_score(y_test, y_pred))

x_train shape is (3700, 256) and x_test shape is (1300, 256) I have received the following accuracy results with the different values of C:

C = 2.0 => accuracy = 72.3%

C = 10.0 => accuracy = 82.9%

C = 100.0 => accuracy = 90.2%

C = 1000.0 => accuracy = 91.1%

C = 1500.0 => accuracy = 91.2%

Based on "Kent Munthe Caspersen" answer on this page, in an SVM model, we look for a hyperplane with the largest minimum margin, and a hyperplane that correctly separates as many instances as possible.

Also I think C, as the regularisation parameter, prevents overfitting. So does the model explained above, suffers from overfitting and if so, then how do I find the appropriate value of C?

Thanks

$\endgroup$
4
  • $\begingroup$ Thanks for clarifying. Now, turning to the question of overfitting, can you provide a definition of overfitting? How can you apply that definition to your observations here? Does that definition seem to fit? Why or why not? $\endgroup$
    – Sycorax
    Commented Jan 25, 2021 at 16:17
  • $\begingroup$ @Sycorax Overfitting is when a model acquires the detail and noise from training data to the degree that the performance of the model has a negative effect on new data. And about applying this definition to this situation, I should add when I use the model to an unseen new data, the accuracy is very low like around 20%. $\endgroup$
    – Coder
    Commented Jan 25, 2021 at 16:31
  • $\begingroup$ Sounds like you need to tune C to find a value that doesn't result in overfitting. We have lots of threads about this. stats.stackexchange.com/search?q=tune+c+%5Bsvm%5D $\endgroup$
    – Sycorax
    Commented Jan 25, 2021 at 16:46
  • $\begingroup$ @Sycorax Thank you. I will look into them one by one, Hope to find the answer. $\endgroup$
    – Coder
    Commented Jan 25, 2021 at 18:21

0

Browse other questions tagged or ask your own question.