![]() |
KSquare Utilities
|
#include <TrainingProcess2.h>
Public Types | |
| typedef TrainingProcess2 * | TrainingProcess2Ptr |
| enum | WhenToRebuild { WhenToRebuild::AlwaysRebuild, WhenToRebuild::NotUpToDate, WhenToRebuild::NotValid, WhenToRebuild::NeverRebuild } |
Public Member Functions | |
| TrainingProcess2 () | |
| The default constructor; What will be used when creating an instance while reading in from a XML Stream file. All members will be set to default values. The XMLRead method. More... | |
| virtual | ~TrainingProcess2 () |
| void | Abort (bool _abort) |
| bool | Abort () const |
| const KKB::DateTime & | BuildDateTime () const |
| void | BuildTrainingProcess (TrainingConfiguration2Const *_config, WhenToRebuild _whenToRebuild, FeatureVectorListPtr _trainingExamples, bool _takeOwnerShipOfTrainingExamples, bool _checkForDuplicates, VolConstBool &_cancelFlag, RunLog &_log) |
| Call this method just after you construct a new instance of "TrainingProcess2". More... | |
| TrainingConfiguration2Const * | Config () |
| VectorKKStr | ConfigFileFormatErrors () const |
| If there is a config file; will return a list of its FormatErrors (). More... | |
| const KKStr & | ConfigFileName () const |
| void | CreateModelsFromTrainingData (WhenToRebuild whenToRebuild, VolConstBool &cancelFlag, RunLog &log) |
| kkint32 | DuplicateCount () const |
| kkint32 | DuplicateDataCount () const |
| MLClassListPtr | ExtractFullHierachyOfClasses () const |
| Extracts the list of classes including ones from Sub-Classifiers. More... | |
| bool | FeaturesAlreadyNormalized () const |
| void | FeaturesAlreadyNormalized (bool _featuresAlreadyNormalized) |
| FactoryFVProducerPtr | FvFactoryProducer () const |
| FeatureVectorListPtr | Images () |
| void | LoadPrevTrainedOtherwiseRebuild (bool _forceRebuild, bool _checkForDuplicates) |
| kkint32 | MemoryConsumedEstimated () const |
| MLClassListPtr | MLClasses () const |
| SVMModelPtr | Model3 () |
| KKStr | ModelDescription () const |
| Model::ModelTypes | ModelType () const |
| KKStr | ModelTypeStr () const |
| kkint32 | NumOfSupportVectors () const |
| ModelOldSVMPtr | OldSVMModel () const |
| ModelParamPtr | Parameters () const |
| ClassProbList const * | PriorProbability () const |
| virtual void | ReadXML (XmlStream &s, XmlTagConstPtr tag, VolConstBool &cancelFlag, RunLog &log) |
| void | ReportTraningClassStatistics (std::ostream &report) |
| void | SaveTrainingProcess (RunLog &log) |
| Saves the built training model into the Save file in Xml Format. More... | |
| TrainingProcess2ListPtr | SubTrainingProcesses () const |
| void | SupportVectorStatistics (kkint32 &numSVs, kkint32 &totalNumSVs) |
| ModelPtr | TrainedModel () const |
| TrainingProcess2Ptr | TrainingProcessLeft () |
| summary> Returns back pointer to 2nd classifier of Dual Classifier; if not a Dual classifier will return back NULL. More... | |
| TrainingProcess2Ptr | TrainingProcessRight () |
| double | TrainingTime () const |
| void | ValidateConfiguration () |
| virtual void | WriteXML (const KKStr &varName, std::ostream &o) const |
Static Public Member Functions | |
| static TrainingProcess2Ptr | CreateTrainingProcess (TrainingConfiguration2Const *config, bool checkForDuplicates, WhenToRebuild whenToRebuild, bool saveTrainedModel, VolConstBool &cancelFlag, RunLog &log) |
| static TrainingProcess2Ptr | CreateTrainingProcessForLevel (TrainingConfiguration2Const *config, kkuint32 level, VolConstBool &cancelFlag, RunLog &log) |
| static TrainingProcess2Ptr | CreateTrainingProcessForLevel (const KKStr &configFileName, kkuint32 level, VolConstBool &cancelFlag, RunLog &log) |
| static TrainingProcess2Ptr | CreateTrainingProcessFromTrainingExamples (TrainingConfiguration2Const *config, FeatureVectorListPtr trainingExamples, bool takeOwnershipOfTrainingExamples, bool featuresAlreadyNormalized, VolConstBool &cancelFlag, RunLog &log) |
| Will Construct an instance using provided list of examples rather than loading from training library. More... | |
| static FeatureVectorListPtr | ExtractTrainingClassFeatures (TrainingConfiguration2ConstPtr config, KKB::DateTime &latestImageTimeStamp, bool &changesMadeToTrainingLibraries, VolConstBool &cancelFlag, RunLog &log) |
| static TrainingProcess2Ptr | LoadExistingTrainingProcess (const KKStr &configRootName, VolConstBool &cancelFlag, RunLog &log) |
| Loads an existing TrainingProcess; if one does not exist will return NULL. More... | |
Definition at line 78 of file TrainingProcess2.h.
Definition at line 81 of file TrainingProcess2.h.
|
strong |
| Enumerator | |
|---|---|
| AlwaysRebuild | |
| NotUpToDate | |
| NotValid | |
| NeverRebuild | |
Definition at line 83 of file TrainingProcess2.h.
| TrainingProcess2::TrainingProcess2 | ( | ) |
The default constructor; What will be used when creating an instance while reading in from a XML Stream file. All members will be set to default values. The XMLRead method.
Definition at line 405 of file TrainingProcess2.cpp.
References KKB::DateTime::DateTime(), and KKB::KKStr::KKStr().
Referenced by CreateTrainingProcess(), and CreateTrainingProcessForLevel().
|
virtual |
Definition at line 434 of file TrainingProcess2.cpp.
|
inline |
Definition at line 243 of file TrainingProcess2.h.
Referenced by CreateModelsFromTrainingData(), and ReadXML().
|
inline |
Definition at line 245 of file TrainingProcess2.h.
Referenced by BuildTrainingProcess(), KKMLL::Classifier2::Classifier2(), CreateTrainingProcess(), and KKMLL::ModelDual::TrainModel().
|
inline |
Definition at line 246 of file TrainingProcess2.h.
Referenced by CreateTrainingProcess().
| void TrainingProcess2::BuildTrainingProcess | ( | TrainingConfiguration2Const * | _config, |
| WhenToRebuild | _whenToRebuild, | ||
| FeatureVectorListPtr | _trainingExamples, | ||
| bool | _takeOwnerShipOfTrainingExamples, | ||
| bool | _checkForDuplicates, | ||
| VolConstBool & | _cancelFlag, | ||
| RunLog & | _log | ||
| ) |
Call this method just after you construct a new instance of "TrainingProcess2".
| [in] | _config | |
| [in] | _whenToRebuild | Used for any sub classifiers that this instance of TrainingProcess2 might need to build. |
| [in] | _trainingExamples | |
| [in] | _takeOwnerShipOfTrainingExamples | If true this instance of 'TrainingProcess2' will take ownership of '_trainingExamples' and delete it when done with them. |
| [in] | _checkForDuplicates | If true will remove duplicate examples from '_trainingExamples'. |
| [in] | _cancelFlag | |
| [in] | _log |
Definition at line 506 of file TrainingProcess2.cpp.
References Abort(), KKMLL::TrainingConfiguration2::ConfigFileNameSpecified(), CreateModelsFromTrainingData(), KKMLL::TrainingConfiguration2::Duplicate(), KKMLL::TrainingConfiguration2::FvFactoryProducer(), KKB::RunLog::Level(), and KKB::KKStr::operator=().
Referenced by CreateTrainingProcess(), and CreateTrainingProcessForLevel().
|
inline |
Definition at line 247 of file TrainingProcess2.h.
Referenced by KKMLL::Classifier2::Classifier2().
| VectorKKStr TrainingProcess2::ConfigFileFormatErrors | ( | ) | const |
If there is a config file; will return a list of its FormatErrors ().
Definition at line 1113 of file TrainingProcess2.cpp.
References KKB::VectorKKStr::VectorKKStr().
|
inline |
Definition at line 248 of file TrainingProcess2.h.
Referenced by KKMLL::ModelDual::Description().
| void TrainingProcess2::CreateModelsFromTrainingData | ( | WhenToRebuild | whenToRebuild, |
| VolConstBool & | cancelFlag, | ||
| RunLog & | log | ||
| ) |
< false = DON'T check for duplicates.
Definition at line 938 of file TrainingProcess2.cpp.
References Abort(), KKMLL::Model::CreateAModel(), KKMLL::FactoryFVProducer::FileDesc(), KKMLL::TrainingConfiguration2::FvFactoryProducer(), KKMLL::FeatureVectorList::GetClassDistribution(), KKMLL::Model::MLClassesNewInstance(), KKMLL::TrainingConfiguration2::ModelingMethod(), KKMLL::TrainingConfiguration2::ModelParameters(), KKB::DateTime::operator=(), KKB::osGetLocalDateTime(), KKB::osGetRootName(), KKMLL::Model::TrainModel(), and KKMLL::Model::ValidModel().
Referenced by BuildTrainingProcess().
|
static |
summary>Build a new model from scratch for the specified class level removing duplicate training examples.
remarks> Using the parameter level will construct a classifier that groups classes together by group hierarchy. Underscore characters in the class name will be used to differentiate group levels. Ex: Crustacean_Copepod_Calanoid has three levels of grouping where Crustacean belongs to level 1, Copeod to level 2, and Calanoid to level 3. /remarks> param name="config"> Configuration that will provide parameters such as classes and their related directories where training examples are found and sub-classifiers. /param> param name="level"> The grouping level to build a classifier for. Ex: if level = 2 is specified and referring to the class name "Crustacean_Copepod_Calanoid" above all classes that start with "Crustacean_Copepod</em>" will be combined as one logical class. /param> param name="cancelFlag"> Will monitor if it ever is set to true will stop processing at earliest convenience and return to caller. /param> param name="log"> Logging file.
< true = Take ownership of 'trainingExamples'.
< true = Take ownership of 'trainingExamples'.
Definition at line 91 of file TrainingProcess2.cpp.
References Abort(), AlwaysRebuild, BuildDateTime(), BuildTrainingProcess(), KKB::KKStr::Concat(), KKMLL::TrainingConfiguration2::ConfigRootName(), ExtractTrainingClassFeatures(), KKMLL::TrainingConfiguration2::GetEffectiveConfigFileName(), LoadExistingTrainingProcess(), NeverRebuild, NotValid, KKB::DateTime::operator<(), KKB::osGetFileDateTime(), SaveTrainingProcess(), and TrainingProcess2().
|
static |
summary> Build a new model from scratch for the specified class level removing duplicate training examples.
remarks> Using the parameter level will construct a classifier that groups classes together by group hierarchy. Underscore characters in the class name will be used to differentiate group levels. Ex: Crustacean_Copepod_Calanoid has three levels of grouping where Crustacean, Copepod, and Calanoid belong to levels 1, 2, 3 respectively. /remarks> param name="configFileName"> Name of Configuration file that is to be used to construct instance of TrainingConfiguration2. Will provide parameters such as classes and their related directories where training examples are found and sub-classifiers. /param> param name="level"> The grouping level to build a classifier for. Ex: if level = 2 is specified and referring to the class name Crustacean_Copepod_Calanoid above all classes that start with Crustacean_Copepod will be combined as one logical class. /param> param name="cancelFlag"> Will monitor if it ever is set to true will stop processing at earliest convenience and return to caller.
param name="log">Logging file.
< true = Take ownership of 'trainingExamples'
Definition at line 248 of file TrainingProcess2.cpp.
References AlwaysRebuild, BuildTrainingProcess(), KKB::KKStr::Concat(), KKMLL::DuplicateImages::DuplicateImages(), KKMLL::TrainingConfiguration2::ExtractClassList(), KKMLL::FeatureVectorList::ExtractExamplesForHierarchyLevel(), ExtractTrainingClassFeatures(), KKMLL::FeatureVectorList::FileDesc(), KKMLL::TrainingConfiguration2::FvFactoryProducer(), KKMLL::TrainingConfiguration2::GenerateAConfiguraionForAHierarchialLevel(), KKMLL::DuplicateImages::PurgeDuplicates(), and TrainingProcess2().
|
static |
Definition at line 316 of file TrainingProcess2.cpp.
References KKMLL::TrainingConfiguration2::Load(), and KKMLL::TrainingConfiguration2::TrainingConfiguration2().
|
static |
Will Construct an instance using provided list of examples rather than loading from training library.
Training examples are typically loaded from a training library as specified in the TrainingConfiguration2 structure. Rather than loading and/or computing feature data it will utilize the feature-vectors provided by the 'trainingExamples' parameter.
| [in] | config | A configuration that is already loaded in memory. |
| [in] | trainingExamples | Training data to train classifier with. |
| [in] | takeOwnershipOfTrainingExamples | If set to true then we will take ownership of the feature-vectors in 'trainingExamples'. This means we are free to modify or delete them as needed. If this flag is set to false will make duplicate copy of the feature-vectors if it is required to modify them; such as normalize them. |
| [in] | featuresAlreadyNormalized | If set to true will assume that all features in the training data are normalized. |
| [in] | cancelFlag | Will monitor if it ever is set to true will stop processing at earliest convenience and return to caller. |
| [in] | log | Logging file. |
Definition at line 352 of file TrainingProcess2.cpp.
Referenced by KKMLL::ModelDual::TrainModel().
|
inline |
Definition at line 250 of file TrainingProcess2.h.
|
inline |
Definition at line 251 of file TrainingProcess2.h.
| MLClassListPtr TrainingProcess2::ExtractFullHierachyOfClasses | ( | ) | const |
Extracts the list of classes including ones from Sub-Classifiers.
Definition at line 1095 of file TrainingProcess2.cpp.
References KKMLL::TrainingConfiguration2::ExtractFullHierachyOfClasses(), and KKMLL::MLClassList::MLClassList().
|
static |
Definition at line 756 of file TrainingProcess2.cpp.
References KKMLL::FeatureVectorList::AddQueue(), KKMLL::TrainingConfiguration2::FvFactoryProducer(), KKMLL::FactoryFVProducer::ManufacturFeatureVectorList(), KKMLL::TrainingConfiguration2::MlClasses(), KKMLL::MLClassList::MLClassList(), KKMLL::TrainingConfiguration2::NoiseTrainingClass(), KKB::DateTime::operator=(), KKB::DateTime::operator>(), and KKMLL::TrainingConfiguration2::TrainingClasses().
Referenced by CreateTrainingProcess(), and CreateTrainingProcessForLevel().
|
inline |
Definition at line 252 of file TrainingProcess2.h.
Referenced by KKMLL::Classifier2::Classifier2().
|
inline |
Definition at line 270 of file TrainingProcess2.h.
|
inline |
Definition at line 253 of file TrainingProcess2.h.
|
inline |
Definition at line 254 of file TrainingProcess2.h.
|
static |
Loads an existing TrainingProcess; if one does not exist will return NULL.
| [in] | configRootName | Root name of training model; |
| [in] | cancelFlag | Will monitor if it ever is set to true will stop processing at earliest convenience and return to caller. |
| [in] | log | Logging file. |
Definition at line 52 of file TrainingProcess2.cpp.
References KKB::KKStr::Concat(), KKMLL::TrainingConfiguration2::GetEffectiveConfigFileName(), KKB::XmlStream::GetNextToken(), KKB::KKStr::operator+(), KKB::osFileExists(), KKB::osRemoveExtension(), and KKB::XmlStream::XmlStream().
Referenced by CreateTrainingProcess().
| void KKMLL::TrainingProcess2::LoadPrevTrainedOtherwiseRebuild | ( | bool | _forceRebuild, |
| bool | _checkForDuplicates | ||
| ) |
| kkint32 TrainingProcess2::MemoryConsumedEstimated | ( | ) | const |
Definition at line 471 of file TrainingProcess2.cpp.
References KKMLL::ClassProbList::MemoryConsumedEstimated(), KKMLL::Model::MemoryConsumedEstimated(), KKMLL::MLClassList::MemoryConsumedEstimated(), KKB::KKStr::MemoryConsumedEstimated(), KKMLL::TrainingProcess2List::MemoryConsumedEstimated(), and KKMLL::FeatureVectorList::MemoryConsumedEstimated().
Referenced by KKMLL::ModelDual::MemoryConsumedEstimated(), and KKMLL::TrainingProcess2List::MemoryConsumedEstimated().
|
inline |
Definition at line 255 of file TrainingProcess2.h.
Referenced by KKMLL::Classifier2::Classifier2().
| SVMModelPtr TrainingProcess2::Model3 | ( | ) |
Definition at line 620 of file TrainingProcess2.cpp.
References OldSVMModel(), and KKMLL::ModelOldSVM::SvmModel().
| KKStr TrainingProcess2::ModelDescription | ( | ) | const |
Definition at line 590 of file TrainingProcess2.cpp.
References KKMLL::Model::Description().
Referenced by KKMLL::ModelDual::ProbabilitiesByClassDual().
| Model::ModelTypes TrainingProcess2::ModelType | ( | ) | const |
Definition at line 600 of file TrainingProcess2.cpp.
References KKMLL::Model::ModelType(), and KKMLL::Model::Null.
| KKStr TrainingProcess2::ModelTypeStr | ( | ) | const |
Definition at line 610 of file TrainingProcess2.cpp.
References KKMLL::Model::ModelTypeStr().
Referenced by KKMLL::ModelDual::Description().
| kkint32 TrainingProcess2::NumOfSupportVectors | ( | ) | const |
Definition at line 1044 of file TrainingProcess2.cpp.
References KKMLL::ModelOldSVM::NumOfSupportVectors(), and OldSVMModel().
Referenced by KKMLL::ModelDual::NumOfSupportVectors().
| ModelOldSVMPtr TrainingProcess2::OldSVMModel | ( | ) | const |
Definition at line 580 of file TrainingProcess2.cpp.
References KKMLL::Model::ModelType(), and KKMLL::Model::OldSVM.
Referenced by Model3(), NumOfSupportVectors(), and SupportVectorStatistics().
| ModelParamPtr TrainingProcess2::Parameters | ( | ) | const |
|
inline |
Definition at line 262 of file TrainingProcess2.h.
Referenced by KKMLL::Classifier2::PriorProbability().
|
virtual |
Definition at line 1237 of file TrainingProcess2.cpp.
References Abort(), KKB::KKStr::Concat(), KKB::KKStr::EqualIgnoreCase(), KKMLL::FactoryFVProducer::FileDesc(), KKMLL::TrainingConfiguration2::FvFactoryProducer(), KKB::XmlStream::GetNextToken(), KKMLL::FactoryFVProducer::LookUpFactory(), KKMLL::Model::MLClasses(), NotValid, KKMLL::MLClassList::operator!=(), KKB::DateTime::operator=(), KKB::XmlElement::SectionName(), KKMLL::TrainingConfiguration2::SubClassifiers(), KKMLL::XmlElementModel::TakeOwnership(), KKMLL::XmlElementMLClassNameList::TakeOwnership(), KKB::XmlElement::ToBool(), KKB::XmlToken::tokElement, KKB::XmlToken::TokenType(), KKB::XmlElement::ToKKStr(), KKMLL::Model::ValidModel(), KKB::XmlElementDateTime::Value(), and KKB::XmlElement::VarName().
| void TrainingProcess2::ReportTraningClassStatistics | ( | std::ostream & | report | ) |
Definition at line 889 of file TrainingProcess2.cpp.
References KKMLL::FeatureVectorList::PrintClassStatistics().
| void TrainingProcess2::SaveTrainingProcess | ( | RunLog & | log | ) |
Saves the built training model into the Save file in Xml Format.
Definition at line 556 of file TrainingProcess2.cpp.
References KKMLL::TrainingConfiguration2::ConfigFileNameSpecified(), KKMLL::TrainingConfiguration2::GetEffectiveConfigFileName(), KKB::KKStr::operator+(), KKB::KKStr::operator=(), and KKB::osRemoveExtension().
Referenced by CreateTrainingProcess().
|
inline |
Definition at line 264 of file TrainingProcess2.h.
summary> Returns back pointer to 1st classifier of Dual Classifier; if not a Dual classifier will return back NULL. Keep in mind that you will not own this classifier and that it can be deleted at any time. /summary>
Definition at line 1055 of file TrainingProcess2.cpp.
References OldSVMModel(), and KKMLL::ModelOldSVM::SupportVectorStatistics().
|
inline |
Definition at line 265 of file TrainingProcess2.h.
Referenced by KKMLL::Classifier2::Classifier2().
| TrainingProcess2Ptr TrainingProcess2::TrainingProcessLeft | ( | ) |
summary> Returns back pointer to 2nd classifier of Dual Classifier; if not a Dual classifier will return back NULL.
Definition at line 1069 of file TrainingProcess2.cpp.
References KKMLL::Model::Dual, KKMLL::Model::ModelType(), and KKMLL::ModelDual::Trainer1().
| TrainingProcess2Ptr TrainingProcess2::TrainingProcessRight | ( | ) |
Definition at line 1078 of file TrainingProcess2.cpp.
References KKMLL::Model::Dual, KKMLL::Model::ModelType(), and KKMLL::ModelDual::Trainer2().
| double TrainingProcess2::TrainingTime | ( | ) | const |
| void KKMLL::TrainingProcess2::ValidateConfiguration | ( | ) |
|
virtual |
Definition at line 1185 of file TrainingProcess2.cpp.
References KKB::XmlTag::AddAtribute(), KKB::KKStr::Empty(), KKMLL::FactoryFVProducer::Name(), KKB::XmlTag::tagEnd, KKB::XmlTag::tagStart, KKMLL::ClassProbList::WriteXML(), KKB::XmlTag::WriteXML(), KKMLL::TrainingConfiguration2::WriteXML(), KKMLL::Model::WriteXML(), KKB::XmlElementBool::WriteXML(), KKB::XmlElementDateTime::WriteXML(), KKB::KKStr::WriteXML(), KKMLL::XmlElementMLClassNameList::WriteXML(), and KKB::XmlTag::XmlTag().
Referenced by KKMLL::ModelDual::WriteXML().