September 2019
Intermediate to advanced
420 pages
10h 29m
English
In OpenCV, SVMs are built, trained, and scored the same exact way as every other learning algorithm we have encountered so far, using the following four steps:
In [6]: import cv2... svm = cv2.ml.SVM_create()
As shown in the following command, there are different modes in which we can operate an SVM. For now, all we care about is the case we discussed in the previous example: an SVM that tries to partition the data with a straight line. This can be specified with the setKernel method:
In [7]: svm.setKernel(cv2.ml.SVM_LINEAR)
In [8]: svm.train(X_train, cv2.ml.ROW_SAMPLE, y_train) ...
Read now
Unlock full access