- *Type of SVM*. We choose here the type @ref cv::ml::SVM::C_SVC "C_SVC" that can be used for
@endcode
n-class classification (n \f$\geq\f$ 2). The important feature of this type is that it deals
- *Type of SVM*. We choose here the type **ml::SVM::C_SVC** that can be used for n-class
with imperfect separation of classes (i.e. when the training data is non-linearly separable).
classification (n \f$\geq\f$ 2). This parameter is defined in the attribute
This feature is not important here since the data is linearly separable and we chose this SVM
*ml::SVM::Params.svmType*.
type only for being the most commonly used.
The important feature of the type of SVM **CvSVM::C_SVC** deals with imperfect separation of classes (i.e. when the training data is non-linearly separable). This feature is not important here since the data is linearly separable and we chose this SVM type only for being the most commonly used.
- *Type of SVM kernel*. We have not talked about kernel functions since they are not
- *Type of SVM kernel*. We have not talked about kernel functions since they are not
interesting for the training data we are dealing with. Nevertheless, let's explain briefly
interesting for the training data we are dealing with. Nevertheless, let's explain briefly now
now the main idea behind a kernel function. It is a mapping done to the training data to
the main idea behind a kernel function. It is a mapping done to the training data to improve
improve its resemblance to a linearly separable set of data. This mapping consists of
its resemblance to a linearly separable set of data. This mapping consists of increasing the
increasing the dimensionality of the data and is done efficiently using a kernel function.
dimensionality of the data and is done efficiently using a kernel function. We choose here the
We choose here the type **ml::SVM::LINEAR** which means that no mapping is done. This
type @ref cv::ml::SVM::LINEAR "LINEAR" which means that no mapping is done. This parameter is
parameter is defined in the attribute *ml::SVMParams.kernel_type*.
defined using cv::ml::SVM::setKernel.
- *Termination criteria of the algorithm*. The SVM training procedure is implemented solving a
- *Termination criteria of the algorithm*. The SVM training procedure is implemented solving a
constrained quadratic optimization problem in an **iterative** fashion. Here we specify a
constrained quadratic optimization problem in an **iterative** fashion. Here we specify a
maximum number of iterations and a tolerance error so we allow the algorithm to finish in
maximum number of iterations and a tolerance error so we allow the algorithm to finish in
less number of steps even if the optimal hyperplane has not been computed yet. This
less number of steps even if the optimal hyperplane has not been computed yet. This
parameter is defined in a structure @ref cv::cvTermCriteria .
parameter is defined in a structure @ref cv::TermCriteria .
-# **Train the SVM**
-# **Train the SVM**
We call the method @ref cv::ml::SVM::train to build the SVM model.