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

get_prep_info_class_svmT_get_prep_info_class_svmget_prep_info_class_svmGetPrepInfoClassSvmGetPrepInfoClassSvm (Operator)

Name

get_prep_info_class_svmT_get_prep_info_class_svmget_prep_info_class_svmGetPrepInfoClassSvmGetPrepInfoClassSvm — Compute the information content of the preprocessed feature vectors of a support vector machine

Signature

get_prep_info_class_svm( : : SVMHandle, Preprocessing : InformationCont, CumInformationCont)

Herror T_get_prep_info_class_svm(const Htuple SVMHandle, const Htuple Preprocessing, Htuple* InformationCont, Htuple* CumInformationCont)

Herror get_prep_info_class_svm(const HTuple& SVMHandle, const HTuple& Preprocessing, HTuple* InformationCont, HTuple* CumInformationCont)

HTuple HClassSvm::GetPrepInfoClassSvm(const HTuple& Preprocessing, HTuple* CumInformationCont) const

void HOperatorSetX.GetPrepInfoClassSvm(
[in] VARIANT SVMHandle, [in] VARIANT Preprocessing, [out] VARIANT* InformationCont, [out] VARIANT* CumInformationCont)

VARIANT HClassSvmX.GetPrepInfoClassSvm(
[in] BSTR Preprocessing, [out] VARIANT* CumInformationCont)

static void HOperatorSet.GetPrepInfoClassSvm(HTuple SVMHandle, HTuple preprocessing, out HTuple informationCont, out HTuple cumInformationCont)

HTuple HClassSvm.GetPrepInfoClassSvm(string preprocessing, out HTuple cumInformationCont)

Description

get_prep_info_class_svmget_prep_info_class_svmget_prep_info_class_svmGetPrepInfoClassSvmGetPrepInfoClassSvm computes the information content of the training vectors that have been transformed with the preprocessing given by PreprocessingPreprocessingPreprocessingPreprocessingpreprocessing. PreprocessingPreprocessingPreprocessingPreprocessingpreprocessing can be set to 'principal_components'"principal_components""principal_components""principal_components""principal_components" or 'canonical_variates'"canonical_variates""canonical_variates""canonical_variates""canonical_variates". The preprocessing methods are described with create_class_svmcreate_class_svmcreate_class_svmCreateClassSvmCreateClassSvm. The information content is derived from the variations of the transformed components of the feature vector, i.e., it is computed solely based on the training data, independent of any error rate on the training data. The information content is computed for all relevant components of the transformed feature vectors (NumFeatures for 'principal_components'"principal_components""principal_components""principal_components""principal_components" and min(NumClasses - 1, NumFeatures) for 'canonical_variates'"canonical_variates""canonical_variates""canonical_variates""canonical_variates", see create_class_svmcreate_class_svmcreate_class_svmCreateClassSvmCreateClassSvm), and is returned in InformationContInformationContInformationContInformationContinformationCont as a number between 0 and 1. To convert the information content into a percentage, it simply needs to be multiplied by 100. The cumulative information content of the first n components is returned in the n-th component of CumInformationContCumInformationContCumInformationContCumInformationContcumInformationCont, i.e., CumInformationContCumInformationContCumInformationContCumInformationContcumInformationCont contains the sums of the first n elements of InformationContInformationContInformationContInformationContinformationCont. To use get_prep_info_class_svmget_prep_info_class_svmget_prep_info_class_svmGetPrepInfoClassSvmGetPrepInfoClassSvm, a sufficient number of samples must be added to the support vector machine (SVM) given by SVMHandleSVMHandleSVMHandleSVMHandleSVMHandle by using add_sample_class_svmadd_sample_class_svmadd_sample_class_svmAddSampleClassSvmAddSampleClassSvm or read_samples_class_svmread_samples_class_svmread_samples_class_svmReadSamplesClassSvmReadSamplesClassSvm.

InformationContInformationContInformationContInformationContinformationCont and CumInformationContCumInformationContCumInformationContCumInformationContcumInformationCont can be used to decide how many components of the transformed feature vectors contain relevant information. An often used criterion is to require that the transformed data must represent x% (e.g., 90%) of the data. This can be decided easily from the first value of CumInformationContCumInformationContCumInformationContCumInformationContcumInformationCont that lies above x%. The number thus obtained can be used as the value for NumComponents in a new call to create_class_svmcreate_class_svmcreate_class_svmCreateClassSvmCreateClassSvm. The call to get_prep_info_class_svmget_prep_info_class_svmget_prep_info_class_svmGetPrepInfoClassSvmGetPrepInfoClassSvm already requires the creation of an SVM, and hence the setting of NumComponents in create_class_svmcreate_class_svmcreate_class_svmCreateClassSvmCreateClassSvm to an initial value. However, when get_prep_info_class_svmget_prep_info_class_svmget_prep_info_class_svmGetPrepInfoClassSvmGetPrepInfoClassSvm is called, it is typically not known how many components are relevant, and hence how to set NumComponents in this call. Therefore, the following two-step approach should typically be used to select NumComponents: In a first step, an SVM with the maximum number for NumComponents is created (NumFeatures for 'principal_components'"principal_components""principal_components""principal_components""principal_components" and min(NumClasses - 1, NumFeatures) for 'canonical_variates'"canonical_variates""canonical_variates""canonical_variates""canonical_variates"). Then, the training samples are added to the SVM and are saved in a file using write_samples_class_svmwrite_samples_class_svmwrite_samples_class_svmWriteSamplesClassSvmWriteSamplesClassSvm. Subsequently, get_prep_info_class_svmget_prep_info_class_svmget_prep_info_class_svmGetPrepInfoClassSvmGetPrepInfoClassSvm is used to determine the information content of the components, and with this NumComponents. After this, a new SVM with the desired number of components is created, and the training samples are read with read_samples_class_svmread_samples_class_svmread_samples_class_svmReadSamplesClassSvmReadSamplesClassSvm. Finally, the SVM is trained with train_class_svmtrain_class_svmtrain_class_svmTrainClassSvmTrainClassSvm.

Parallelization

Parameters

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

SVM handle.

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

Type of preprocessing used to transform the feature vectors.

Default value: 'principal_components' "principal_components" "principal_components" "principal_components" "principal_components"

List of values: 'principal_components'"principal_components""principal_components""principal_components""principal_components", 'canonical_variates'"canonical_variates""canonical_variates""canonical_variates""canonical_variates"

InformationContInformationContInformationContInformationContinformationCont (output_control)  real-array HTupleHTupleVARIANTHtuple (real) (double) (double) (double) (double)

Relative information content of the transformed feature vectors.

CumInformationContCumInformationContCumInformationContCumInformationContcumInformationCont (output_control)  real-array HTupleHTupleVARIANTHtuple (real) (double) (double) (double) (double)

Cumulative information content of the transformed feature vectors.

Example (HDevelop)

* Create the initial SVM
create_class_svm (NumFeatures, 'rbf', 0.01, 0.01, NumClasses,\
                  'one-versus-all', 'normalization', NumFeatures,\
                  SVMHandle)
* Generate and add the training data
for J := 0 to NData-1 by 1
    * Generate training features and classes
    * Data = [...]
    * Class = ...
    add_sample_class_svm (SVMHandle, Data, Class)
endfor
write_samples_class_svm (SVMHandle, 'samples.mtf')
* Compute the information content of the transformed features
get_prep_info_class_svm (SVMHandle, 'principal_components',\
                         InformationCont, CumInformationCont)
* Determine NComp by inspecting InformationCont and CumInformationCont
* NComp = [...]
clear_class_svm (SVMHandle)
* Create the actual SVM
create_class_svm (NumFeatures, 'rbf', 0.01, 0.01, NumClasses,\
                  'one-versus-all', 'principal_components', NComp, SVMHandle)
* Train the SVM
read_samples_class_svm (SVMHandle, 'samples.mtf')
train_class_svm (SVMHandle, 0.001, 'default')
write_class_svm (SVMHandle, 'classifier.svm')
clear_class_svm (SVMHandle)

Result

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

get_prep_info_class_svmget_prep_info_class_svmget_prep_info_class_svmGetPrepInfoClassSvmGetPrepInfoClassSvm may return the error 9211 (Matrix is not positive definite) if PreprocessingPreprocessingPreprocessingPreprocessingpreprocessing = 'canonical_variates'"canonical_variates""canonical_variates""canonical_variates""canonical_variates" is used. This typically indicates that not enough training samples have been stored for each class.

Possible Predecessors

add_sample_class_svmadd_sample_class_svmadd_sample_class_svmAddSampleClassSvmAddSampleClassSvm, read_samples_class_svmread_samples_class_svmread_samples_class_svmReadSamplesClassSvmReadSamplesClassSvm

Possible Successors

clear_class_svmclear_class_svmclear_class_svmClearClassSvmClearClassSvm, create_class_svmcreate_class_svmcreate_class_svmCreateClassSvmCreateClassSvm

References

Christopher M. Bishop: “Neural Networks for Pattern Recognition”; Oxford University Press, Oxford; 1995.
Andrew Webb: “Statistical Pattern Recognition”; Arnold, London; 1999.

Module

Foundation


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