select_feature_set_trainf_knnT_select_feature_set_trainf_knnSelectFeatureSetTrainfKnnSelectFeatureSetTrainfKnnselect_feature_set_trainf_knn (Operator)

Name

select_feature_set_trainf_knnT_select_feature_set_trainf_knnSelectFeatureSetTrainfKnnSelectFeatureSetTrainfKnnselect_feature_set_trainf_knn — Wählt die optimalen Merkmale für ein bestimmtes OCR-Klassifikationsproblem aus.

Signatur

select_feature_set_trainf_knn( : : TrainingFile, FeatureList, SelectionMethod, Width, Height, GenParamName, GenParamValue : 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 GenParamName, const Htuple GenParamValue, Htuple* OCRHandle, Htuple* FeatureSet, Htuple* Score)

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

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

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

HTuple HOCRKnn::SelectFeatureSetTrainfKnn(const char* TrainingFile, const char* FeatureList, const char* SelectionMethod, Hlong Width, Hlong Height, const HTuple& GenParamName, const HTuple& GenParamValue, HTuple* Score)

HTuple HOCRKnn::SelectFeatureSetTrainfKnn(const wchar_t* TrainingFile, const wchar_t* FeatureList, const wchar_t* SelectionMethod, Hlong Width, Hlong Height, const HTuple& GenParamName, const HTuple& GenParamValue, HTuple* Score)   (Nur Windows)

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

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

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

def select_feature_set_trainf_knn(training_file: MaybeSequence[str], feature_list: MaybeSequence[str], selection_method: str, width: int, height: int, gen_param_name: Sequence[str], gen_param_value: Sequence[Union[int, str, float]]) -> Tuple[HHandle, Sequence[str], Sequence[float]]

Beschreibung

select_feature_set_trainf_knnselect_feature_set_trainf_knnSelectFeatureSetTrainfKnnSelectFeatureSetTrainfKnnSelectFeatureSetTrainfKnnselect_feature_set_trainf_knn wählt die optimalen Merkmale für ein bestimmtes OCR-Klassifikationsproblem aus. Die Daten für das OCR-Klassifikationsproblem werden mit der Trainingsdatei TrainingFileTrainingFileTrainingFileTrainingFiletrainingFiletraining_file ausgewählt. Als Klassifikator wird ein k-Nearest-Neighbor-Klassifikator (kNN) verwendet.

Es wird eine Untermenge aller angegebenen OCR-Merkmale gewählt. Alle zu untersuchenden Merkmale werden in FeatureListFeatureListFeatureListFeatureListfeatureListfeature_list spezifiziert. Die Liste der möglichen OCR-Merkmale wird in der Dokumentation von create_ocr_class_knncreate_ocr_class_knnCreateOcrClassKnnCreateOcrClassKnnCreateOcrClassKnncreate_ocr_class_knn näher erläutert. Die letztendlich ausgewählte Merkmalsuntermenge wird in FeatureSetFeatureSetFeatureSetFeatureSetfeatureSetfeature_set zurückgegeben.

select_feature_set_trainf_knnselect_feature_set_trainf_knnSelectFeatureSetTrainfKnnSelectFeatureSetTrainfKnnSelectFeatureSetTrainfKnnselect_feature_set_trainf_knn ist auf OCR-Klassifikationsprobleme spezialisiert und unterstützt nur Merkmale, die in der Auswahlliste stehen. Für andere Merkmale bietet sich somit die Nutzung des generellen Operators select_feature_set_knnselect_feature_set_knnSelectFeatureSetKnnSelectFeatureSetKnnSelectFeatureSetKnnselect_feature_set_knn an.

Für den Selektionsprozess können in SelectionMethodSelectionMethodSelectionMethodSelectionMethodselectionMethodselection_method zwei verschiedene Methoden ausgewählt werden: entweder die Greedy-Variante 'greedy'"greedy""greedy""greedy""greedy""greedy" (das momentan erfolgversprechendste Merkmal wird zur Auswahl hinzugefügt) oder die dynamisch oszillierende Suche 'greedy_oscillating'"greedy_oscillating""greedy_oscillating""greedy_oscillating""greedy_oscillating""greedy_oscillating" (Das momentan erfolgversprechendste Merkmal wird zur Auswahl hinzugefügt. Danach wird getestet ob eines der hinzugefügten Merkmale entbehrlich ist.). Während 'greedy'"greedy""greedy""greedy""greedy""greedy" schneller terminiert, kann 'greedy_oscillating'"greedy_oscillating""greedy_oscillating""greedy_oscillating""greedy_oscillating""greedy_oscillating" bessere Ergebnisse erzielen wenn viele Trainingsdaten vorliegen.

Als Optimierungskriterium dient die Klassifikationsrate, die mit einem zwei-fachen Kreuzvalidierungsverfahren ermittelt wird. Die beste erreichte Klassifikationsrate wird in ScoreScoreScoreScorescorescore zurückgegeben. OCRHandleOCRHandleOCRHandleOCRHandleOCRHandleocrhandle gibt einen Klassifikator zurück, der mit der entsprechenden Featureauswahl parametrisiert und trainiert wurde.

Mit Hilfe der Parameter GenParamNameGenParamNameGenParamNameGenParamNamegenParamNamegen_param_name und GenParamValueGenParamValueGenParamValueGenParamValuegenParamValuegen_param_value können die folgenden Werte gesetzt werden:

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

Anzahl Nachbarn die ermittelt werden, das Erhöhen dieses Wertes führt zu besseren Ergebnissen bei längerer Laufzeit.

Mögliche Werte: 1, 2, 5, 10

Defaultwert: 1

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

die Anzahl an Suchbäumen im k-NN

Mögliche Werte: 1, 4, 10

Defaultwert: 4

Achtung

Die Laufzeit dieses Operators kann mit größeren Datensätzen und einer längeren Merkmalsliste unter Umständen sehr lange sein.

Es ist zu beachten, dass dieser Operator nicht aufgerufen werden sollte, wenn für das Training nur ein kleiner Datensatz verfügbar ist. Auf Grund des Risikos der Überanpassung kann der Operator select_feature_set_trainf_knnselect_feature_set_trainf_knnSelectFeatureSetTrainfKnnSelectFeatureSetTrainfKnnSelectFeatureSetTrainfKnnselect_feature_set_trainf_knn zwar einerseits einen Klassifikator mit sehr hohem Score liefern. Andererseits weist der Klassifikator jedoch eine schlechte Erkennungsrate auf, wenn dieser getestet wird.

Ausführungsinformationen

Dieser Operator liefert ein Handle zurück. Es ist zu beachten, dass der Zustand einer Instanz dieses Handletyps durch bestimmte Operatoren geändert werden kann, obwohl das Handle als Eingabeparameter in diesen Operatoren verwendet wird.

Parameter

TrainingFileTrainingFileTrainingFileTrainingFiletrainingFiletraining_file (input_control)  filename.read(-array) HTupleMaybeSequence[str]HTupleHtuple (string) (string) (HString) (char*)

Namen der Trainingsdateien.

Defaultwert: '' "" "" "" "" ""

Dateiendung: .trf, .otr

FeatureListFeatureListFeatureListFeatureListfeatureListfeature_list (input_control)  string(-array) HTupleMaybeSequence[str]HTupleHtuple (string) (string) (HString) (char*)

Merkmale, die zur Klassifikation verwendet werden können.

Defaultwert: ['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"]

Werteliste: '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"

SelectionMethodSelectionMethodSelectionMethodSelectionMethodselectionMethodselection_method (input_control)  string HTuplestrHTupleHtuple (string) (string) (HString) (char*)

Die Methode zur Auswahl der Merkmale.

Defaultwert: 'greedy' "greedy" "greedy" "greedy" "greedy" "greedy"

Werteliste: 'greedy'"greedy""greedy""greedy""greedy""greedy", 'greedy_oscillating'"greedy_oscillating""greedy_oscillating""greedy_oscillating""greedy_oscillating""greedy_oscillating"

WidthWidthWidthWidthwidthwidth (input_control)  integer HTupleintHTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Breite des Rechtecks, auf die die Grauwerte des segmentierten Zeichens skaliert werden.

Defaultwert: 15

HeightHeightHeightHeightheightheight (input_control)  integer HTupleintHTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Höhe des Rechtecks, auf die die Grauwerte des segmentierten Zeichens skaliert werden.

Defaultwert: 16

GenParamNameGenParamNameGenParamNameGenParamNamegenParamNamegen_param_name (input_control)  string-array HTupleSequence[str]HTupleHtuple (string) (string) (HString) (char*)

Namen von (optionalen) Parametern für die Steuerung des Verhaltens verwendeten des k-NN Klassifikators.

Defaultwert: []

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

GenParamValueGenParamValueGenParamValueGenParamValuegenParamValuegen_param_value (input_control)  number-array HTupleSequence[Union[int, str, float]]HTupleHtuple (real / integer / string) (double / int / long / string) (double / Hlong / HString) (double / Hlong / char*)

Die zu den optionalen generischen Parametern gehörenden Werte.

Defaultwert: []

Wertevorschläge: 1, 2, 3

OCRHandleOCRHandleOCRHandleOCRHandleOCRHandleocrhandle (output_control)  ocr_knn HOCRKnn, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)

Ein trainierter k-NN Klassifikator.

FeatureSetFeatureSetFeatureSetFeatureSetfeatureSetfeature_set (output_control)  string-array HTupleSequence[str]HTupleHtuple (string) (string) (HString) (char*)

Die ausgewählten Merkmale.

ScoreScoreScoreScorescorescore (output_control)  real-array HTupleSequence[float]HTupleHtuple (real) (double) (double) (double)

Die Klassifikationsrate die mit dem ausgewählten Merkmalssatz erreicht wurde.

Ergebnis

Sind die Parameterwerte korrekt, dann liefert select_feature_set_trainf_knnselect_feature_set_trainf_knnSelectFeatureSetTrainfKnnSelectFeatureSetTrainfKnnSelectFeatureSetTrainfKnnselect_feature_set_trainf_knn den Wert 2 (H_MSG_TRUE). Gegebenenfalls wird eine Fehlerbehandlung durchgeführt.

Alternativen

select_feature_set_trainf_svmselect_feature_set_trainf_svmSelectFeatureSetTrainfSvmSelectFeatureSetTrainfSvmSelectFeatureSetTrainfSvmselect_feature_set_trainf_svm, select_feature_set_trainf_mlpselect_feature_set_trainf_mlpSelectFeatureSetTrainfMlpSelectFeatureSetTrainfMlpSelectFeatureSetTrainfMlpselect_feature_set_trainf_mlp

Siehe auch

select_feature_set_knnselect_feature_set_knnSelectFeatureSetKnnSelectFeatureSetKnnSelectFeatureSetKnnselect_feature_set_knn

Modul

OCR/OCV