Читать книгу Simulation and Analysis of Mathematical Methods in Real-Time Engineering Applications - Группа авторов - Страница 23

1.2.6 Comparison for KNN and SVM

Оглавление

KNN classifies knowledge based on the distance metric, while SVM needs a proper training process. Because of the optimal design of the SVM, it is guaranteed that the separated data will be separated optimally. KNN is commonly used as multi-class classifiers, while regular binary data belonging to either one class is different from SVM. A One-vs-One and One-vs-All strategy is used for a multiclass SVM. Figure 1.5 explains about hyperplanes are decision boundaries that help classify the data points. Data points falling on either side of the hyperplane can be attributed to different classes. Also, the dimension of the hyperplane depends upon the number of features. In the One-vs-one method, n*(n-1)/2 SVMs must be trained: one SVM for each pair of classes. Among all outcomes of all SVMs, we feed the unknown pattern to the entity and the final decision on the form of data is determined by majority result. This method is often used in the classification of multiple groups. We have to train as many SVMs when it comes to the One-vs-All approach as there are groups of unlabeled data. As in the other method, if given to the SVM with the greatest decision value, we give the unidentified pattern to the system and the final result.


Figure 1.5 Hyperplane in SVM.

Although SVMs look more computationally intensive, this model can be used to predict classes once data training is completed, even when we come across new unlabelled data. In KNN, however, each time we come across a collection of new unlabelled data, the distance metric is determined. In KNN, therefore, we still need to specify the distance metric. There are two major cases of SVMs in which groups can be linearly or non-linearly separable. We use kernel functions such as the Gaussian basis function or polynomials when the classes are non-linearly separable [11].

Therefore, we only have to set the K parameter and select the distance metric appropriate for KNN classification, while in SVMs, if the classes are not linearly separable, we only have to select the R parameter (regularisation term) and also the kernel parameters. Table 1.1 gives the comparison between 2 classifiers to check accuracy.

When we check about accuracy of both of the classifiers, SVMs usually have higher accuracy than KNN as shown [6–8].

When performing the visual studio tests after integrating OpenCV libraries, the accuracy percentage for SVM [7] was found to be 94 percent and 93 percent for KNN [6].

Table 1.1 Accuracy of classifiers.

Classifier Training set Test set Accuracy rate (in %)
SVM 10,000 10,000 98.9
KNN 10,000 10,000 96.47
Simulation and Analysis of Mathematical Methods in Real-Time Engineering Applications

Подняться наверх