0

I am trying to train a linear SVC model (with scikit-learn) for image binary classification problem. For the training, I have about 60k training images, each of them has 1800 pixels. And yes, I really want to use SVM related algorithms instead of deep learning, because it is for learning purpose. But the problem is, the training is taking few hours already, but it is not showing any progress. Before training, I have normalized the pixel values to the range 0-1 by dividing by 255. But what might be the problem here? Any advices what I can tune or pay attention to?

dataX = dataX/255.
dataY = np.ravel(dataY)

X_train, X_test, y_train, y_test = train_test_split(dataX, dataY, test_size=0.1, random_state=24, shuffle=True)

linear_classifier = svm.LinearSVR(random_state=0, tol=1e-5, verbose=1, max_iter=1000)
linear_classifier.fit(X_train, y_train)
  • 2
    Could you provide a [minimal, reproducible example](https://stackoverflow.com/help/minimal-reproducible-example)? As stated right now, the question depends entirely on the data: Were the data, say, all white noise, then that's exactly the behavior you would expect. – fuglede Nov 28 '19 at 21:04
  • I added some code, in the meantime the training was completed with the warning that the model could not converge after having 1000 iterations. Does that mean, I can simply increase the number of iteration? Are there any other options / parameters to tune so it can converge faster? –  Nov 28 '19 at 21:13

1 Answers1

1

If your process is slow, one problem could be that the minimizer is not on the right track for some time. This is also mentioned here: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations

For your the first step could be to change the number of iterations:

 svm.LinearSVR(random_state=0, tol=1e-5, verbose=1, max_iter=10000)

In the documentation you can also find other parameters which you can adjust: https://scikit-learn.org/stable/modules/generated/sklearn.svm.LinearSVC.html

PV8
  • 5,799
  • 7
  • 43
  • 87