ClassesClassesClassesClasses | | | | Operators

select_feature_set_trainf_knnT_select_feature_set_trainf_knnSelectFeatureSetTrainfKnnselect_feature_set_trainf_knnSelectFeatureSetTrainfKnnSelectFeatureSetTrainfKnn (Operator)

Name

select_feature_set_trainf_knnT_select_feature_set_trainf_knnSelectFeatureSetTrainfKnnselect_feature_set_trainf_knnSelectFeatureSetTrainfKnnSelectFeatureSetTrainfKnn — Select an optimal combination of features to classify OCR data.

Signature

select_feature_set_trainf_knn( : : TrainingFile, FeatureList, SelectionMethod, Width, Height, GenParamNames, GenParamValues : OCRHandle, FeatureSet, Score)

Herror T_select_feature_set_trainf_knn(const Htuple TrainingFile, const Htuple FeatureList, const Htuple SelectionMethod, const Htuple Width, const Htuple Height, const Htuple GenParamNames, const Htuple GenParamValues, Htuple* OCRHandle, Htuple* FeatureSet, Htuple* Score)

Herror select_feature_set_trainf_knn(const HTuple& TrainingFile, const HTuple& FeatureList, const HTuple& SelectionMethod, const HTuple& Width, const HTuple& Height, const HTuple& GenParamNames, const HTuple& GenParamValues, HTuple* OCRHandle, HTuple* FeatureSet, HTuple* Score)

HTuple HOCRKnn::SelectFeatureSetTrainfKnn(const HTuple& TrainingFile, const HTuple& FeatureList, const HTuple& SelectionMethod, const HTuple& Width, const HTuple& Height, const HTuple& GenParamNames, const HTuple& GenParamValues, HTuple* Score)

void SelectFeatureSetTrainfKnn(const HTuple& TrainingFile, const HTuple& FeatureList, const HTuple& SelectionMethod, const HTuple& Width, const HTuple& Height, const HTuple& GenParamNames, const HTuple& GenParamValues, HTuple* OCRHandle, HTuple* FeatureSet, HTuple* Score)

HTuple HOCRKnn::SelectFeatureSetTrainfKnn(const HTuple& TrainingFile, const HTuple& FeatureList, const HString& SelectionMethod, Hlong Width, Hlong Height, const HTuple& GenParamNames, const HTuple& GenParamValues, HTuple* Score)

HTuple HOCRKnn::SelectFeatureSetTrainfKnn(const HString& TrainingFile, const HString& FeatureList, const HString& SelectionMethod, Hlong Width, Hlong Height, const HString& GenParamNames, double GenParamValues, HTuple* Score)

HTuple HOCRKnn::SelectFeatureSetTrainfKnn(const char* TrainingFile, const char* FeatureList, const char* SelectionMethod, Hlong Width, Hlong Height, const char* GenParamNames, double GenParamValues, HTuple* Score)

void HOperatorSetX.SelectFeatureSetTrainfKnn(
[in] VARIANT TrainingFile, [in] VARIANT FeatureList, [in] VARIANT SelectionMethod, [in] VARIANT Width, [in] VARIANT Height, [in] VARIANT GenParamNames, [in] VARIANT GenParamValues, [out] VARIANT* OCRHandle, [out] VARIANT* FeatureSet, [out] VARIANT* Score)

VARIANT HOCRKnnX.SelectFeatureSetTrainfKnn(
[in] VARIANT TrainingFile, [in] VARIANT FeatureList, [in] BSTR SelectionMethod, [in] Hlong Width, [in] Hlong Height, [in] VARIANT GenParamNames, [in] VARIANT GenParamValues, [out] VARIANT* Score)

static void HOperatorSet.SelectFeatureSetTrainfKnn(HTuple trainingFile, HTuple featureList, HTuple selectionMethod, HTuple width, HTuple height, HTuple genParamNames, HTuple genParamValues, out HTuple OCRHandle, out HTuple featureSet, out HTuple score)

HTuple HOCRKnn.SelectFeatureSetTrainfKnn(HTuple trainingFile, HTuple featureList, string selectionMethod, int width, int height, HTuple genParamNames, HTuple genParamValues, out HTuple score)

HTuple HOCRKnn.SelectFeatureSetTrainfKnn(string trainingFile, string featureList, string selectionMethod, int width, int height, string genParamNames, double genParamValues, out HTuple score)

Description

select_feature_set_trainf_knnselect_feature_set_trainf_knnSelectFeatureSetTrainfKnnselect_feature_set_trainf_knnSelectFeatureSetTrainfKnnSelectFeatureSetTrainfKnn selects an optimal combination of features, to classify the data given in the training file TrainingFileTrainingFileTrainingFileTrainingFileTrainingFiletrainingFile with a k-Nearest Neighbor classifier, for details see create_ocr_class_knncreate_ocr_class_knnCreateOcrClassKnncreate_ocr_class_knnCreateOcrClassKnnCreateOcrClassKnn.

Possible features are all OCR features listed and explained in create_ocr_class_knncreate_ocr_class_knnCreateOcrClassKnncreate_ocr_class_knnCreateOcrClassKnnCreateOcrClassKnn. All candidates which should be tested can be specified in FeatureListFeatureListFeatureListFeatureListFeatureListfeatureList. A subset of these features is returned as selected features in FeatureSetFeatureSetFeatureSetFeatureSetFeatureSetfeatureSet.

select_feature_set_trainf_knnselect_feature_set_trainf_knnSelectFeatureSetTrainfKnnselect_feature_set_trainf_knnSelectFeatureSetTrainfKnnSelectFeatureSetTrainfKnn is specialized on OCR problems and only supports the features in the list mentioned before. In order to use other features, please use the more general operator select_feature_set_knnselect_feature_set_knnSelectFeatureSetKnnselect_feature_set_knnSelectFeatureSetKnnSelectFeatureSetKnn.

The selection method SelectionMethodSelectionMethodSelectionMethodSelectionMethodSelectionMethodselectionMethod is either a greedy search 'greedy'"greedy""greedy""greedy""greedy""greedy" (iteratively add the feature with highest gain) or the dynamically oscillating search 'greedy_oscillating'"greedy_oscillating""greedy_oscillating""greedy_oscillating""greedy_oscillating""greedy_oscillating" (add the feature with highest gain and test then if any of the already added features can be left out without great loss). The method 'greedy'"greedy""greedy""greedy""greedy""greedy" is generally preferable, since it is faster. Only in cases when a large training set is available the method 'greedy_oscillating'"greedy_oscillating""greedy_oscillating""greedy_oscillating""greedy_oscillating""greedy_oscillating" might return better results.

The optimization criterion is the classification rate of a two-fold cross-validation of the training data. The best achieved value is returned in ScoreScoreScoreScoreScorescore.

The k-NN classifier can be parametrized using the following values in GenParamNamesGenParamNamesGenParamNamesGenParamNamesGenParamNamesgenParamNames and GenParamValuesGenParamValuesGenParamValuesGenParamValuesGenParamValuesgenParamValues:

'num_neighbors'"num_neighbors""num_neighbors""num_neighbors""num_neighbors""num_neighbors":

The number of minimally evaluated nodes, increase this value for high dimensional data.

Possible values: '1'"1""1""1""1""1", '2'"2""2""2""2""2", '5'"5""5""5""5""5", '10'"10""10""10""10""10"

Default value: '1'"1""1""1""1""1"

'num_trees'"num_trees""num_trees""num_trees""num_trees""num_trees":

Number of search trees in the k-NN classifier

Possible values: '1'"1""1""1""1""1", '4'"4""4""4""4""4", '10'"10""10""10""10""10"

Default Value: '4'"4""4""4""4""4"

Attention

This operator may take considerable time, depending on the size of the data set in the training file, and the number of features.

Please note, that this operator should not be called, if only a small set of training data is available. Due to the risk of overfitting the operator select_feature_set_trainf_knnselect_feature_set_trainf_knnSelectFeatureSetTrainfKnnselect_feature_set_trainf_knnSelectFeatureSetTrainfKnnSelectFeatureSetTrainfKnn may deliver a classifier with a very high score. However, the classifier may perfom poorly when tested.

Parallelization

Parameters

TrainingFileTrainingFileTrainingFileTrainingFileTrainingFiletrainingFile (input_control)  filename.read(-array) HTupleHTupleHTupleVARIANTHtuple (string) (string) (HString) (char*) (BSTR) (char*)

Names of the training files.

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

File extension: .trf, .otr

FeatureListFeatureListFeatureListFeatureListFeatureListfeatureList (input_control)  string(-array) HTupleHTupleHTupleVARIANTHtuple (string) (string) (HString) (char*) (BSTR) (char*)

List of features that should be considered for selection.

Default value: ['zoom_factor','ratio','width','height','foreground','foreground_grid_9','foreground_grid_16','anisometry','compactness','convexity','moments_region_2nd_invar','moments_region_2nd_rel_invar','moments_region_3rd_invar','moments_central','phi','num_connect','num_holes','projection_horizontal','projection_vertical','projection_horizontal_invar','projection_vertical_invar','chord_histo','num_runs','pixel','pixel_invar','pixel_binary','gradient_8dir','cooc','moments_gray_plane'] ["zoom_factor","ratio","width","height","foreground","foreground_grid_9","foreground_grid_16","anisometry","compactness","convexity","moments_region_2nd_invar","moments_region_2nd_rel_invar","moments_region_3rd_invar","moments_central","phi","num_connect","num_holes","projection_horizontal","projection_vertical","projection_horizontal_invar","projection_vertical_invar","chord_histo","num_runs","pixel","pixel_invar","pixel_binary","gradient_8dir","cooc","moments_gray_plane"] ["zoom_factor","ratio","width","height","foreground","foreground_grid_9","foreground_grid_16","anisometry","compactness","convexity","moments_region_2nd_invar","moments_region_2nd_rel_invar","moments_region_3rd_invar","moments_central","phi","num_connect","num_holes","projection_horizontal","projection_vertical","projection_horizontal_invar","projection_vertical_invar","chord_histo","num_runs","pixel","pixel_invar","pixel_binary","gradient_8dir","cooc","moments_gray_plane"] ["zoom_factor","ratio","width","height","foreground","foreground_grid_9","foreground_grid_16","anisometry","compactness","convexity","moments_region_2nd_invar","moments_region_2nd_rel_invar","moments_region_3rd_invar","moments_central","phi","num_connect","num_holes","projection_horizontal","projection_vertical","projection_horizontal_invar","projection_vertical_invar","chord_histo","num_runs","pixel","pixel_invar","pixel_binary","gradient_8dir","cooc","moments_gray_plane"] ["zoom_factor","ratio","width","height","foreground","foreground_grid_9","foreground_grid_16","anisometry","compactness","convexity","moments_region_2nd_invar","moments_region_2nd_rel_invar","moments_region_3rd_invar","moments_central","phi","num_connect","num_holes","projection_horizontal","projection_vertical","projection_horizontal_invar","projection_vertical_invar","chord_histo","num_runs","pixel","pixel_invar","pixel_binary","gradient_8dir","cooc","moments_gray_plane"] ["zoom_factor","ratio","width","height","foreground","foreground_grid_9","foreground_grid_16","anisometry","compactness","convexity","moments_region_2nd_invar","moments_region_2nd_rel_invar","moments_region_3rd_invar","moments_central","phi","num_connect","num_holes","projection_horizontal","projection_vertical","projection_horizontal_invar","projection_vertical_invar","chord_histo","num_runs","pixel","pixel_invar","pixel_binary","gradient_8dir","cooc","moments_gray_plane"]

List of values: 'anisometry'"anisometry""anisometry""anisometry""anisometry""anisometry", 'chord_histo'"chord_histo""chord_histo""chord_histo""chord_histo""chord_histo", 'compactness'"compactness""compactness""compactness""compactness""compactness", 'convexity'"convexity""convexity""convexity""convexity""convexity", 'cooc'"cooc""cooc""cooc""cooc""cooc", 'default'"default""default""default""default""default", 'foreground'"foreground""foreground""foreground""foreground""foreground", 'foreground_grid_16'"foreground_grid_16""foreground_grid_16""foreground_grid_16""foreground_grid_16""foreground_grid_16", 'foreground_grid_9'"foreground_grid_9""foreground_grid_9""foreground_grid_9""foreground_grid_9""foreground_grid_9", 'gradient_8dir'"gradient_8dir""gradient_8dir""gradient_8dir""gradient_8dir""gradient_8dir", 'height'"height""height""height""height""height", 'moments_central'"moments_central""moments_central""moments_central""moments_central""moments_central", 'moments_gray_plane'"moments_gray_plane""moments_gray_plane""moments_gray_plane""moments_gray_plane""moments_gray_plane", 'moments_region_2nd_invar'"moments_region_2nd_invar""moments_region_2nd_invar""moments_region_2nd_invar""moments_region_2nd_invar""moments_region_2nd_invar", 'moments_region_2nd_rel_invar'"moments_region_2nd_rel_invar""moments_region_2nd_rel_invar""moments_region_2nd_rel_invar""moments_region_2nd_rel_invar""moments_region_2nd_rel_invar", 'moments_region_3rd_invar'"moments_region_3rd_invar""moments_region_3rd_invar""moments_region_3rd_invar""moments_region_3rd_invar""moments_region_3rd_invar", 'num_connect'"num_connect""num_connect""num_connect""num_connect""num_connect", 'num_holes'"num_holes""num_holes""num_holes""num_holes""num_holes", 'num_runs'"num_runs""num_runs""num_runs""num_runs""num_runs", 'phi'"phi""phi""phi""phi""phi", 'pixel'"pixel""pixel""pixel""pixel""pixel", 'pixel_binary'"pixel_binary""pixel_binary""pixel_binary""pixel_binary""pixel_binary", 'pixel_invar'"pixel_invar""pixel_invar""pixel_invar""pixel_invar""pixel_invar", 'projection_horizontal'"projection_horizontal""projection_horizontal""projection_horizontal""projection_horizontal""projection_horizontal", 'projection_horizontal_invar'"projection_horizontal_invar""projection_horizontal_invar""projection_horizontal_invar""projection_horizontal_invar""projection_horizontal_invar", 'projection_vertical'"projection_vertical""projection_vertical""projection_vertical""projection_vertical""projection_vertical", 'projection_vertical_invar'"projection_vertical_invar""projection_vertical_invar""projection_vertical_invar""projection_vertical_invar""projection_vertical_invar", 'ratio'"ratio""ratio""ratio""ratio""ratio", 'width'"width""width""width""width""width", 'zoom_factor'"zoom_factor""zoom_factor""zoom_factor""zoom_factor""zoom_factor"

SelectionMethodSelectionMethodSelectionMethodSelectionMethodSelectionMethodselectionMethod (input_control)  string HTupleHTupleHTupleVARIANTHtuple (string) (string) (HString) (char*) (BSTR) (char*)

Method to perform the selection.

Default value: 'greedy' "greedy" "greedy" "greedy" "greedy" "greedy"

List of values: 'greedy'"greedy""greedy""greedy""greedy""greedy", 'greedy_oscillating'"greedy_oscillating""greedy_oscillating""greedy_oscillating""greedy_oscillating""greedy_oscillating"

WidthWidthWidthWidthWidthwidth (input_control)  integer HTupleHTupleHTupleVARIANTHtuple (integer) (int / long) (Hlong) (Hlong) (Hlong) (Hlong)

Width of the rectangle to which the gray values of the segmented character are zoomed.

Default value: 15

HeightHeightHeightHeightHeightheight (input_control)  integer HTupleHTupleHTupleVARIANTHtuple (integer) (int / long) (Hlong) (Hlong) (Hlong) (Hlong)

Height of the rectangle to which the gray values of the segmented character are zoomed.

Default value: 16

GenParamNamesGenParamNamesGenParamNamesGenParamNamesGenParamNamesgenParamNames (input_control)  string(-array) HTupleHTupleHTupleVARIANTHtuple (string) (string) (HString) (char*) (BSTR) (char*)

Names of generic parameters to configure the selection process and the classifier.

Default value: []

List of values: 'num_neighbors'"num_neighbors""num_neighbors""num_neighbors""num_neighbors""num_neighbors"

GenParamValuesGenParamValuesGenParamValuesGenParamValuesGenParamValuesgenParamValues (input_control)  number(-array) HTupleHTupleHTupleVARIANTHtuple (real / integer / string) (double / int / long / string) (double / Hlong / HString) (double / Hlong / char*) (double / Hlong / BSTR) (double / Hlong / char*)

Values of generic parameters to configure the selection process and the classifier.

Default value: []

Suggested values: 1, 2, 3

OCRHandleOCRHandleOCRHandleOCRHandleOCRHandleOCRHandle (output_control)  ocr_knn HOCRKnn, HTupleHTupleHOCRKnn, HTupleHOCRKnnX, VARIANTHtuple (integer) (IntPtr) (Hlong) (Hlong) (Hlong) (Hlong)

Trained OCR-k-NN classifier.

FeatureSetFeatureSetFeatureSetFeatureSetFeatureSetfeatureSet (output_control)  string-array HTupleHTupleHTupleVARIANTHtuple (string) (string) (HString) (char*) (BSTR) (char*)

Selected feature set, contains only entries from FeatureListFeatureListFeatureListFeatureListFeatureListfeatureList.

ScoreScoreScoreScoreScorescore (output_control)  real-array HTupleHTupleHTupleVARIANTHtuple (real) (double) (double) (double) (double) (double)

Achieved score using tow-fold cross-validation.

Result

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

Alternatives

select_feature_set_trainf_svmselect_feature_set_trainf_svmSelectFeatureSetTrainfSvmselect_feature_set_trainf_svmSelectFeatureSetTrainfSvmSelectFeatureSetTrainfSvm, select_feature_set_trainf_mlpselect_feature_set_trainf_mlpSelectFeatureSetTrainfMlpselect_feature_set_trainf_mlpSelectFeatureSetTrainfMlpSelectFeatureSetTrainfMlp

See also

select_feature_set_knnselect_feature_set_knnSelectFeatureSetKnnselect_feature_set_knnSelectFeatureSetKnnSelectFeatureSetKnn

Module

OCR/OCV


ClassesClassesClassesClasses | | | | Operators