get_prep_info_ocr_class_svmT_get_prep_info_ocr_class_svmGetPrepInfoOcrClassSvmGetPrepInfoOcrClassSvmget_prep_info_ocr_class_svm (Operator)

Name

get_prep_info_ocr_class_svmT_get_prep_info_ocr_class_svmGetPrepInfoOcrClassSvmGetPrepInfoOcrClassSvmget_prep_info_ocr_class_svm — Berechnung des Informationsgehaltes der vorverarbeiteten Merkmalsvektoren eines OCR-Klassifikators.

Signatur

get_prep_info_ocr_class_svm( : : OCRHandle, TrainingFile, Preprocessing : InformationCont, CumInformationCont)

Herror T_get_prep_info_ocr_class_svm(const Htuple OCRHandle, const Htuple TrainingFile, const Htuple Preprocessing, Htuple* InformationCont, Htuple* CumInformationCont)

void GetPrepInfoOcrClassSvm(const HTuple& OCRHandle, const HTuple& TrainingFile, const HTuple& Preprocessing, HTuple* InformationCont, HTuple* CumInformationCont)

HTuple HOCRSvm::GetPrepInfoOcrClassSvm(const HTuple& TrainingFile, const HString& Preprocessing, HTuple* CumInformationCont) const

HTuple HOCRSvm::GetPrepInfoOcrClassSvm(const HString& TrainingFile, const HString& Preprocessing, HTuple* CumInformationCont) const

HTuple HOCRSvm::GetPrepInfoOcrClassSvm(const char* TrainingFile, const char* Preprocessing, HTuple* CumInformationCont) const

HTuple HOCRSvm::GetPrepInfoOcrClassSvm(const wchar_t* TrainingFile, const wchar_t* Preprocessing, HTuple* CumInformationCont) const   (Nur Windows)

static void HOperatorSet.GetPrepInfoOcrClassSvm(HTuple OCRHandle, HTuple trainingFile, HTuple preprocessing, out HTuple informationCont, out HTuple cumInformationCont)

HTuple HOCRSvm.GetPrepInfoOcrClassSvm(HTuple trainingFile, string preprocessing, out HTuple cumInformationCont)

HTuple HOCRSvm.GetPrepInfoOcrClassSvm(string trainingFile, string preprocessing, out HTuple cumInformationCont)

def get_prep_info_ocr_class_svm(ocrhandle: HHandle, training_file: MaybeSequence[str], preprocessing: str) -> Tuple[Sequence[float], Sequence[float]]

Beschreibung

get_prep_info_ocr_class_svmget_prep_info_ocr_class_svmGetPrepInfoOcrClassSvmGetPrepInfoOcrClassSvmGetPrepInfoOcrClassSvmget_prep_info_ocr_class_svm berechnet den Informationsgehalt der mit der durch PreprocessingPreprocessingPreprocessingPreprocessingpreprocessingpreprocessing gegebenen Vorverarbeitung transformierten Komponenten der Trainingsvektoren. PreprocessingPreprocessingPreprocessingPreprocessingpreprocessingpreprocessing kann auf 'principal_components'"principal_components""principal_components""principal_components""principal_components""principal_components" oder 'canonical_variates'"canonical_variates""canonical_variates""canonical_variates""canonical_variates""canonical_variates" gesetzt werden. Der OCR-Klassifikator OCRHandleOCRHandleOCRHandleOCRHandleOCRHandleocrhandle muss mit create_ocr_class_svmcreate_ocr_class_svmCreateOcrClassSvmCreateOcrClassSvmCreateOcrClassSvmcreate_ocr_class_svm erzeugt worden sein. Die zugrundeliegenden Vorverarbeitungen sind bei create_class_svmcreate_class_svmCreateClassSvmCreateClassSvmCreateClassSvmcreate_class_svm beschrieben. Der Informationsgehalt wird aus die Variation der transformierten Komponenten der Trainingsvektoren berechnet, d.h. er wird rein aufgrund der Trainingsdaten unabhängig von einer Fehlerrate bei einer Klassifikation der Trainingsdaten berechnet. Der Informationsgehalt wird für alle relevanten Komponenten der transformierten Merkmalsvektoren (NumFeatures für 'principal_components'"principal_components""principal_components""principal_components""principal_components""principal_components" und min(NumClasses - 1, NumFeatures) für 'canonical_variates'"canonical_variates""canonical_variates""canonical_variates""canonical_variates""canonical_variates", siehe create_class_svmcreate_class_svmCreateClassSvmCreateClassSvmCreateClassSvmcreate_class_svm) in InformationContInformationContInformationContInformationContinformationContinformation_cont zurückgegeben. Der Informationsgehalt wird als eine Zahl zwischen 0 und 1 dargestellt. Ein prozentualer Informationsgehalt kann leicht durch Multiplikation mit 100 berechnet werden. Der kumulierte Informationsgehalt der ersten n Komponenten wird in der n-ten Komponente von CumInformationContCumInformationContCumInformationContCumInformationContcumInformationContcum_information_cont zurückgegeben, d.h. CumInformationContCumInformationContCumInformationContCumInformationContcumInformationContcum_information_cont enthält die Summen der ersten n Elemente von InformationContInformationContInformationContInformationContinformationContinformation_cont. Um get_prep_info_ocr_class_svmget_prep_info_ocr_class_svmGetPrepInfoOcrClassSvmGetPrepInfoOcrClassSvmGetPrepInfoOcrClassSvmget_prep_info_ocr_class_svm verwenden zu können, müssen Trainingsmuster in den durch TrainingFileTrainingFileTrainingFileTrainingFiletrainingFiletraining_file angegebenen Trainingsdateien abgespeichert werden (siehe write_ocr_trainfwrite_ocr_trainfWriteOcrTrainfWriteOcrTrainfWriteOcrTrainfwrite_ocr_trainf).

InformationContInformationContInformationContInformationContinformationContinformation_cont und CumInformationContCumInformationContCumInformationContCumInformationContcumInformationContcum_information_cont können dazu verwendet werden, um zu entscheiden, wie viele Komponenten der transformierten Merkmalsvektoren relevante Information enthalten. Ein oft verwendetes Kriterium ist z.B. zu verlangen, dass die transformierten Daten x% (z.B. 90%) der Daten enthalten sollten. Dies kann leicht anhand des ersten Wertes von CumInformationContCumInformationContCumInformationContCumInformationContcumInformationContcum_information_cont, der über x% liegt, bestimmt werden. Der so erhaltene Wert kann bei einem neuerlichen Aufruf von create_ocr_class_svmcreate_ocr_class_svmCreateOcrClassSvmCreateOcrClassSvmCreateOcrClassSvmcreate_ocr_class_svm als NumComponents verwendet werden. Da zum Aufruf von get_prep_info_ocr_class_svmget_prep_info_ocr_class_svmGetPrepInfoOcrClassSvmGetPrepInfoOcrClassSvmGetPrepInfoOcrClassSvmget_prep_info_ocr_class_svm schon ein Klassifikator mit create_ocr_class_svmcreate_ocr_class_svmCreateOcrClassSvmCreateOcrClassSvmCreateOcrClassSvmcreate_ocr_class_svm erzeugt werden muss, also auch ein initialer Wert von NumComponents bei create_ocr_class_svmcreate_ocr_class_svmCreateOcrClassSvmCreateOcrClassSvmCreateOcrClassSvmcreate_ocr_class_svm angegeben werden muss, aber bei Verwendung von get_prep_info_ocr_class_svmget_prep_info_ocr_class_svmGetPrepInfoOcrClassSvmGetPrepInfoOcrClassSvmGetPrepInfoOcrClassSvmget_prep_info_ocr_class_svm typischerweise noch nicht bekannt ist, wie viele Komponenten relevant sind, empfiehlt sich folgendes zweistufiges Vorgehen, um NumComponents zu bestimmen: In einem ersten Schritt wird ein Klassifikator mit der maximalen Anzahl von NumComponents (NumFeatures für 'principal_components'"principal_components""principal_components""principal_components""principal_components""principal_components" und min(NumClasses - 1, NumFeatures) für 'canonical_variates'"canonical_variates""canonical_variates""canonical_variates""canonical_variates""canonical_variates") erzeugt. Dann werden die Trainingsmuster mit write_ocr_trainfwrite_ocr_trainfWriteOcrTrainfWriteOcrTrainfWriteOcrTrainfwrite_ocr_trainf in einer Datei gespeichert. Anschließend wird mit get_prep_info_ocr_class_svmget_prep_info_ocr_class_svmGetPrepInfoOcrClassSvmGetPrepInfoOcrClassSvmGetPrepInfoOcrClassSvmget_prep_info_ocr_class_svm der Informationsgehalt der Komponenten und somit NumComponents bestimmt. Danach wird ein neuer Klassifikator mit der gewünschten Anzahl Komponenten erzeugt und der Klassifikator mit trainf_ocr_class_svmtrainf_ocr_class_svmTrainfOcrClassSvmTrainfOcrClassSvmTrainfOcrClassSvmtrainf_ocr_class_svm trainiert.

Ausführungsinformationen

Parameter

OCRHandleOCRHandleOCRHandleOCRHandleOCRHandleocrhandle (input_control)  ocr_svm HOCRSvm, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)

Handle des OCR-Klassifikators.

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

Name(n) der Trainingsdatei(en).

Defaultwert: 'ocr.trf' "ocr.trf" "ocr.trf" "ocr.trf" "ocr.trf" "ocr.trf"

Dateiendung: .trf, .otr

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

Art der Vorverarbeitung (Transformation) der Merkmalsvektoren.

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

Werteliste: 'canonical_variates'"canonical_variates""canonical_variates""canonical_variates""canonical_variates""canonical_variates", 'principal_components'"principal_components""principal_components""principal_components""principal_components""principal_components"

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

Relativer Informationsgehalt der transformierten Merkmalsvektoren.

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

Kumulierter Informationsgehalt der transformierten Merkmalsvektoren.

Beispiel (HDevelop)

* Create the initial OCR classifier.
read_ocr_trainf_names ('ocr.trf', CharacterNames, CharacterCount)
create_ocr_class_svm (8, 10, 'constant', 'default', CharacterNames, \
                      'rbf', 0.01, 0.01, 'one-versus-one', \
                      'principal_components', 81, OCRHandle)
* Get the information content of the transformed feature vectors.
get_prep_info_ocr_class_svm (OCRHandle, 'ocr.trf', 'principal_components', \
                             InformationCont, CumInformationCont)
* Determine the number of transformed components.
* NumComp = [...]
* Create the final OCR classifier.
create_ocr_class_svm (8, 10, 'constant', 'default', CharacterNames, \
                      'rbf', 0.01, 0.01,'one-versus-one', \
                      'principal_components', NumComp, OCRHandle)
* Train the final classifier.
trainf_ocr_class_svm (OCRHandle, 'ocr.trf', 0.001, 'default')
write_ocr_class_svm (OCRHandle, 'ocr.osc')

Ergebnis

Sind die Parameterwerte korrekt, dann liefert get_prep_info_ocr_class_svmget_prep_info_ocr_class_svmGetPrepInfoOcrClassSvmGetPrepInfoOcrClassSvmGetPrepInfoOcrClassSvmget_prep_info_ocr_class_svm den Wert TRUE. Gegebenenfalls wird eine Fehlerbehandlung durchgeführt.

Falls get_prep_info_ocr_class_svmget_prep_info_ocr_class_svmGetPrepInfoOcrClassSvmGetPrepInfoOcrClassSvmGetPrepInfoOcrClassSvmget_prep_info_ocr_class_svm den Fehler 9211 (Matrix ist nicht positiv definit) bei PreprocessingPreprocessingPreprocessingPreprocessingpreprocessingpreprocessing = 'canonical_variates'"canonical_variates""canonical_variates""canonical_variates""canonical_variates""canonical_variates" zurückliefert, bedeutet dies typischerweise, dass für die verschiedenen Klassen zu wenige Trainingsmuster gespeichert worden sind.

Vorgänger

create_ocr_class_svmcreate_ocr_class_svmCreateOcrClassSvmCreateOcrClassSvmCreateOcrClassSvmcreate_ocr_class_svm, write_ocr_trainfwrite_ocr_trainfWriteOcrTrainfWriteOcrTrainfWriteOcrTrainfwrite_ocr_trainf, append_ocr_trainfappend_ocr_trainfAppendOcrTrainfAppendOcrTrainfAppendOcrTrainfappend_ocr_trainf, write_ocr_trainf_imagewrite_ocr_trainf_imageWriteOcrTrainfImageWriteOcrTrainfImageWriteOcrTrainfImagewrite_ocr_trainf_image

Nachfolger

clear_ocr_class_svmclear_ocr_class_svmClearOcrClassSvmClearOcrClassSvmClearOcrClassSvmclear_ocr_class_svm, create_ocr_class_svmcreate_ocr_class_svmCreateOcrClassSvmCreateOcrClassSvmCreateOcrClassSvmcreate_ocr_class_svm

Modul

OCR/OCV