2

I want to see if the model is converging on my cross validation. How do i increase or decrease epochs in sklearn.svm.SVC? currently:

SVM_Model = SVC(gamma='auto')
SVM_Model.fit(X_train,y_train)

Also how can I see a progress bar during the training?

flames
  • 161
  • 1
  • 3
  • 8

1 Answers1

2

You have the combination of max_iter and tol to achieve the convergence.

max_iter int, optional (default=-1)
Hard limit on iterations within solver, or -1 for no limit.

tol float, optional (default=1e-3)
Tolerance for stopping criterion.

Progress bar support is currently not available in Sklearn now but you can use the verbose param to know the progress.

verbose bool, default: False
Enable verbose output. Note that this setting takes advantage of a per-process runtime setting in libsvm that, if enabled, may not work properly in a multithreaded context.

Community
  • 1
  • 1
Venkatachalam
  • 16,288
  • 9
  • 49
  • 77
  • I follow this code: https://medium.com/analytics-vidhya/image-classification-using-machine-learning-support-vector-machine-svm-dc7a0ec92e01 I identify as "key" command from that link this one: "model.fit(x_train,y_train)" . Where do I put "max_iter" and "tol " in order to do the training with epochs? – just_learning May 23 '21 at 09:31
  • 1
    class constructor params. during the SVC class initiation. Refer to the examples [here](https://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html) – Venkatachalam May 23 '21 at 11:23
  • Ok, I changed the command to this: svc=svm.SVC(probability=True, max_iter= 1) and I get this error: /usr/local/lib/python3.7/dist-packages/sklearn/svm/_base.py:231: ConvergenceWarning: Solver terminated early (max_iter=1). Consider pre-processing your data with StandardScaler or MinMaxScaler. % self.max_iter, ConvergenceWarning) – just_learning May 23 '21 at 11:56
  • I am trying this solution: https://stackoverflow.com/questions/54163095/probabilistic-svm-regression but nothing seems to work with my problem... Any idea? – just_learning May 23 '21 at 19:34
  • 1
    max_iter =1 is a very low value, try somewhere around 100 or 200. – Venkatachalam May 24 '21 at 11:29