HALCON Reference Manual 10.0.2
Table of Contents / Classification / Support Vector Machines ClassesClassesClasses | | | Operators

reduce_class_svmreduce_class_svmreduce_class_svmReduceClassSvmReduceClassSvm (Operator)

Name

reduce_class_svmreduce_class_svmreduce_class_svmReduceClassSvmReduceClassSvm — Approximate a trained support vector machine by a reduced support vector machine for faster classification.

Signature

reduce_class_svm( : : SVMHandle, Method, MinRemainingSV, MaxError : SVMHandleReduced)

Herror reduce_class_svm(const Hlong SVMHandle, const char* Method, const Hlong MinRemainingSV, double MaxError, Hlong* SVMHandleReduced)

Herror T_reduce_class_svm(const Htuple SVMHandle, const Htuple Method, const Htuple MinRemainingSV, const Htuple MaxError, Htuple* SVMHandleReduced)

Herror reduce_class_svm(const HTuple& SVMHandle, const HTuple& Method, const HTuple& MinRemainingSV, const HTuple& MaxError, Hlong* SVMHandleReduced)

HClassSvm HClassSvm::ReduceClassSvm(const HTuple& Method, const HTuple& MinRemainingSV, const HTuple& MaxError) const

void HOperatorSetX.ReduceClassSvm(
[in] VARIANT SVMHandle, [in] VARIANT Method, [in] VARIANT MinRemainingSV, [in] VARIANT MaxError, [out] VARIANT* SVMHandleReduced)

IHClassSvmX* HClassSvmX.ReduceClassSvm(
[in] BSTR Method, [in] Hlong MinRemainingSV, [in] double MaxError)

static void HOperatorSet.ReduceClassSvm(HTuple SVMHandle, HTuple method, HTuple minRemainingSV, HTuple maxError, out HTuple SVMHandleReduced)

HClassSvm HClassSvm.ReduceClassSvm(string method, int minRemainingSV, double maxError)

Description

As described in create_class_svmcreate_class_svmcreate_class_svmCreateClassSvmCreateClassSvm, the classification time of a SVM depends on the number of kernel evaluations between the support vectors and the feature vectors. While the length of the data vectors can be reduced in a preprocessing step like 'pricipal_components'"pricipal_components""pricipal_components""pricipal_components""pricipal_components" or 'canonical_variates'"canonical_variates""canonical_variates""canonical_variates""canonical_variates" (see create_class_svmcreate_class_svmcreate_class_svmCreateClassSvmCreateClassSvm for details), the number of resulting SV depends on the complexity of the classification problem. The number of SVs is determined during training. To further reduce classification time, the number of SVs can be reduced by approximating the original separating hyperplane with fewer SVs than originally required. For this purpose, a copy of the original SVM provided by SVMHandleSVMHandleSVMHandleSVMHandleSVMHandle is created and returned in SVMHandleReducedSVMHandleReducedSVMHandleReducedSVMHandleReducedSVMHandleReduced. This new SVM has the same parametrization as the original SVM, but a different SV expansion. The training samples that are included in SVMHandleSVMHandleSVMHandleSVMHandleSVMHandle are not copied. The original SVM is not modified by reduce_class_svmreduce_class_svmreduce_class_svmReduceClassSvmReduceClassSvm.

The reduction method is selected with MethodMethodMethodMethodmethod. Currently, only a bottom up approch is supported, which iteratively merges SVs. The algorithm stops if either the minimum number of SVs is reached (MinRemainingSVMinRemainingSVMinRemainingSVMinRemainingSVminRemainingSV) or if the accumulated maximum error exceeds the threshold MaxErrorMaxErrorMaxErrorMaxErrormaxError. Note that the approximation reduces the complexity of the hyperplane and thereby leads to a deteriorated classification rate. A common approch is therefore to start from a small MaxErrorMaxErrorMaxErrorMaxErrormaxError e.g., 0.001, and to increase its value step by step. To control the reduction ratio, at each step the number of remaining SVs is determined with get_support_vector_num_class_svmget_support_vector_num_class_svmget_support_vector_num_class_svmGetSupportVectorNumClassSvmGetSupportVectorNumClassSvm and the classification rate is checked on a separate test data set with classify_class_svmclassify_class_svmclassify_class_svmClassifyClassSvmClassifyClassSvm.

Parallelization

Parameters

SVMHandleSVMHandleSVMHandleSVMHandleSVMHandle (input_control)  class_svm HClassSvm, HTupleHClassSvm, HTupleHClassSvmX, VARIANTHtuple (integer) (IntPtr) (Hlong) (Hlong) (Hlong)

Original SVM handle.

MethodMethodMethodMethodmethod (input_control)  string HTupleHTupleVARIANTHtuple (string) (string) (char*) (BSTR) (char*)

Type of postprocessing to reduce number of SV.

Default value: 'bottom_up' "bottom_up" "bottom_up" "bottom_up" "bottom_up"

List of values: 'bottom_up'"bottom_up""bottom_up""bottom_up""bottom_up"

MinRemainingSVMinRemainingSVMinRemainingSVMinRemainingSVminRemainingSV (input_control)  integer HTupleHTupleVARIANTHtuple (integer) (int / long) (Hlong) (Hlong) (Hlong)

Minimum number of remaining SVs.

Default value: 2

Suggested values: 2, 3, 4, 5, 7, 10, 15, 20, 30, 50

Restriction: MinRemainingSV >= 2

MaxErrorMaxErrorMaxErrorMaxErrormaxError (input_control)  real HTupleHTupleVARIANTHtuple (real) (double) (double) (double) (double)

Maximum allowed error of reduction.

Default value: 0.001

Suggested values: 0.0001, 0.0002, 0.0005, 0.001, 0.002, 0.005, 0.01, 0.02, 0.05

Restriction: MaxError > 0.0

SVMHandleReducedSVMHandleReducedSVMHandleReducedSVMHandleReducedSVMHandleReduced (output_control)  class_svm HClassSvm, HTupleHClassSvm, HTupleHClassSvmX, VARIANTHtuple (integer) (IntPtr) (Hlong) (Hlong) (Hlong)

SVMHandle of reduced SVM.

Example (HDevelop)

* Train an SVM
create_class_svm (NumFeatures, 'rbf', 0.01, 0.01, NumClasses,\
                  'one-versus-all', 'normalization', NumFeatures,\
                  SVMHandle)
read_samples_class_svm (SVMHandle, 'samples.mtf')
train_class_svm (SVMHandle, 0.001, 'default')
* Create a reduced SVM
reduce_class_svm (SVMHandle, 'bottom_up', 2, 0.01, SVMHandleReduced)
write_class_svm (SVMHandleReduced, 'classifier.svm')
clear_class_svm (SVMHandleReduced)
clear_class_svm (SVMHandle)

Result

If the parameters are valid the operator train_class_svmtrain_class_svmtrain_class_svmTrainClassSvmTrainClassSvm returns the value 2 (H_MSG_TRUE). If necessary, an exception is raised.

Possible Predecessors

train_class_svmtrain_class_svmtrain_class_svmTrainClassSvmTrainClassSvm, get_support_vector_num_class_svmget_support_vector_num_class_svmget_support_vector_num_class_svmGetSupportVectorNumClassSvmGetSupportVectorNumClassSvm

Possible Successors

classify_class_svmclassify_class_svmclassify_class_svmClassifyClassSvmClassifyClassSvm, write_class_svmwrite_class_svmwrite_class_svmWriteClassSvmWriteClassSvm, get_support_vector_num_class_svmget_support_vector_num_class_svmget_support_vector_num_class_svmGetSupportVectorNumClassSvmGetSupportVectorNumClassSvm

See also

train_class_svmtrain_class_svmtrain_class_svmTrainClassSvmTrainClassSvm

Module

Foundation


Table of Contents / Classification / Support Vector Machines ClassesClassesClasses | | | Operators
HALCON Reference Manual 10.0.2 Copyright © 1996-2011 MVTec Software GmbH