Skip to content

reduce_class_svmReduceClassSvmReduceClassSvmreduce_class_svmT_reduce_class_svm🔗

Short description🔗

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

Signature🔗

reduce_class_svm( class_svm SVMHandle, string Method, integer MinRemainingSV, real MaxError, out class_svm SVMHandleReduced )void ReduceClassSvm( const HTuple& SVMHandle, const HTuple& Method, const HTuple& MinRemainingSV, const HTuple& MaxError, HTuple* SVMHandleReduced )static void HOperatorSet.ReduceClassSvm( HTuple SVMHandle, HTuple method, HTuple minRemainingSV, HTuple maxError, out HTuple SVMHandleReduced )def reduce_class_svm( svmhandle: HHandle, method: str, min_remaining_sv: int, max_error: float ) -> HHandle

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

HClassSvm HClassSvm::ReduceClassSvm( const HString& Method, Hlong MinRemainingSV, double MaxError ) const

HClassSvm HClassSvm::ReduceClassSvm( const char* Method, Hlong MinRemainingSV, double MaxError ) const

HClassSvm HClassSvm::ReduceClassSvm( const wchar_t* Method, Hlong MinRemainingSV, double MaxError ) const (Windows only)

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

Description🔗

As described in create_class_svmCreateClassSvm, 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 'principal_components'"principal_components" or 'canonical_variates'"canonical_variates" (see create_class_svmCreateClassSvm 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 SVMHandleSVMHandlesvmhandle is created and returned in SVMHandleReducedSVMHandleReducedsvmhandle_reduced. This new SVM has the same parametrization as the original SVM, but a different SV expansion. The training samples that are included in SVMHandleSVMHandlesvmhandle are not copied. The original SVM is not modified by reduce_class_svmReduceClassSvm.

The reduction method is selected with Methodmethodmethod. Currently, only a bottom up approach is supported, which iteratively merges SVs. The algorithm stops if either the minimum number of SVs is reached (MinRemainingSVminRemainingSVmin_remaining_sv) or if the accumulated maximum error exceeds the threshold MaxErrormaxErrormax_error. Note that the approximation reduces the complexity of the hyperplane and thereby leads to a deteriorated classification rate. A common approach is therefore to start from a small MaxErrormaxErrormax_error e.g., 0.0010.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_svmGetSupportVectorNumClassSvm and the classification rate is checked on a separate test data set with classify_class_svmClassifyClassSvm.

Execution information🔗

Execution information
  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Processed without parallelization.

Parameters🔗

SVMHandleSVMHandlesvmhandle (input_control) class_svm → (handle)HTuple (HHandle)HClassSvm, HTuple (IntPtr)HHandleHtuple (handle)

Original SVM handle.

Methodmethodmethod (input_control) string → (string)HTuple (HString)HTuple (string)strHtuple (char*)

Type of postprocessing to reduce number of SV.

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

MinRemainingSVminRemainingSVmin_remaining_sv (input_control) integer → (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Minimum number of remaining SVs.

Default: 22
Suggested values: 2, 3, 4, 5, 7, 10, 15, 20, 30, 502, 3, 4, 5, 7, 10, 15, 20, 30, 50
Restriction: MinRemainingSV >= 2

MaxErrormaxErrormax_error (input_control) real → (real)HTuple (double)HTuple (double)floatHtuple (double)

Maximum allowed error of reduction.

Default: 0.0010.001
Suggested values: 0.0001, 0.0002, 0.0005, 0.001, 0.002, 0.005, 0.01, 0.02, 0.050.0001, 0.0002, 0.0005, 0.001, 0.002, 0.005, 0.01, 0.02, 0.05
Restriction: MaxError > 0.0

SVMHandleReducedSVMHandleReducedsvmhandle_reduced (output_control) class_svm → (handle)HTuple (HHandle)HClassSvm, HTuple (IntPtr)HHandleHtuple (handle)

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')

Result🔗

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

Combinations with other operators🔗

Combinations

Possible predecessors

train_class_svmTrainClassSvm, get_support_vector_num_class_svmGetSupportVectorNumClassSvm

Possible successors

classify_class_svmClassifyClassSvm, write_class_svmWriteClassSvm, get_support_vector_num_class_svmGetSupportVectorNumClassSvm

See also

train_class_svmTrainClassSvm

Module🔗

Foundation