1
$\begingroup$

I am training a SVM and apply the sklearn learning_curve function on order to get the training and testing error curves. However, although the testing error is decreasing finely, the training error is not growing, as it would be expected to do.

My dataset contains around 25,000 samples, distributed in 9 classes and there are 6 attributes. Here is the code :

dataset=np.loadtxt("data",delimiter=",")
X=dataset[:, 0:6]
Y=dataset[:,6]


train_sizes, train_scores, test_scores=learning_curve(SVC(),X,Y,train_sizes=np.arange(500,15000,500))
train_scores_mean = np.mean(train_scores, axis=1)
test_scores_mean = np.mean(test_scores, axis=1)

plt.figure(figsize=(8, 8))
plt.subplots_adjust()
plt.title("Erreur d'entrainement et de test" )

plt.plot(train_sizes,1-train_scores_mean,label="train error")
plt.plot(train_sizes,1-test_scores_mean,label="test error")
plt.legend()
plt.show()

and the graph is joined.

Could someone help me to understand why the training error is not growing ? Thanks![learning error curves]1

$\endgroup$

1 Answer 1

1
$\begingroup$

You are using the default SVC() which means that you are training a Soft-Margin SVM. Based on the plot, my guess would be that the default value for the parameter C=1.0 is not a good for your data. I would try different values of C, e.g. [0.01, 0.1, 1.0, 10.0, 100.0, 1000.0, 10000.0, 100000.0] and see how this affects the train and cross-validation errors. It seems like your data is not really linearly separable and you should allow more freedom for misclassification during training. SVM has a unique solution for a fixed value of C and it looks like that the solution for the default value of C is not so good.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.