![]() |
KSquare Utilities
|
Base class to all Learning Algorithms. More...
#include <Model.h>
Inheritance diagram for KKMLL::Model:Public Types | |
| typedef Model * | ModelPtr |
| enum | ModelTypes : int { ModelTypes::Null = 0, ModelTypes::OldSVM = 1, ModelTypes::SvmBase = 2, ModelTypes::KNN = 3, ModelTypes::UsfCasCor = 4, ModelTypes::Dual = 5 } |
Public Member Functions | |
| Model () | |
| Model (FactoryFVProducerPtr _factoryFVProducer) | |
| Use this when you are planning on creating a empty model without parameters. More... | |
| Model (const KKStr &_name, const ModelParam &_param, FactoryFVProducerPtr _factoryFVProducer) | |
| Construct a instance of 'Model' using the parameters specified in '_param'. More... | |
| Model (const Model &_madel) | |
| Copy Constructor. More... | |
| virtual | ~Model () |
| Frees any memory allocated by, and owned by the Model. More... | |
| bool | AlreadyNormalized () const |
| virtual KKStr | Description () const |
| virtual ModelPtr | Duplicate () const =0 |
| const FeatureEncoder2 & | Encoder () const |
| FactoryFVProducerPtr | FactoryFVProducer () const |
| virtual FeatureNumListConstPtr | GetFeatureNums () const |
| virtual kkint32 | MemoryConsumedEstimated () const |
| MLClassListPtr | MLClasses () const |
| MLClassListPtr | MLClassesNewInstance () const |
| virtual ModelTypes | ModelType () const =0 |
| virtual KKStr | ModelTypeStr () const |
| const KKStr & | Name () const |
| void | Name (const KKStr &_name) |
| virtual bool | NormalizeNominalAttributes () const |
| ModelParamPtr | Param () const |
| virtual MLClassPtr | Predict (FeatureVectorPtr example, RunLog &log)=0 |
| virtual void | Predict (FeatureVectorPtr example, MLClassPtr knownClass, MLClassPtr &predClass1, MLClassPtr &predClass2, kkint32 &predClass1Votes, kkint32 &predClass2Votes, double &probOfKnownClass, double &predClass1Prob, double &predClass2Prob, kkint32 &numOfWinners, bool &knownClassOneOfTheWinners, double &breakTie, RunLog &log)=0 |
| virtual void | PredictRaw (FeatureVectorPtr example, MLClassPtr &predClass, double &dist) |
| virtual FeatureVectorPtr | PrepExampleForPrediction (FeatureVectorPtr fv, bool &newExampleCreated) |
| Every prediction method in every class that is inherited from this class should call this method before performing there prediction. Such things as Normalization and Feature Encoding. More... | |
| virtual ClassProbListPtr | ProbabilitiesByClass (FeatureVectorPtr example, RunLog &log)=0 |
| virtual void | ProbabilitiesByClass (FeatureVectorPtr example, const MLClassList &_mlClasses, kkint32 *_votes, double *_probabilities, RunLog &_log)=0 |
| virtual void | ProbabilitiesByClass (FeatureVectorPtr _example, const MLClassList &_mlClasses, double *_probabilities, RunLog &_log)=0 |
| Derives predicted probabilities by class. More... | |
| virtual void | ProbabilitiesByClassDual (FeatureVectorPtr example, KKStr &classifier1Desc, KKStr &classifier2Desc, ClassProbListPtr &classifier1Results, ClassProbListPtr &classifier2Results, RunLog &log) |
| Only applied to ModelDual classifier. More... | |
| virtual void | ReadXML (XmlStream &s, XmlTagConstPtr tag, VolConstBool &cancelFlag, RunLog &log)=0 |
| To be implemented by derived classes; the parent classes fields will be updated by the derived class calling ReadXMLModelToken. More... | |
| virtual void | RetrieveCrossProbTable (MLClassList &classes, double **crossProbTable, RunLog &log) |
| const KKStr & | RootFileName () const |
| void | RootFileName (const KKStr &_rootFileName) |
| virtual FeatureNumListConstPtr | SelectedFeatures () const |
| const KKB::DateTime & | TimeSaved () const |
| double | TrainingTime () const |
| void | TrainingTimeEnd () |
| Derived classes call this method to stop the clock for 'trainingTime'. More... | |
| void | TrainingTimeStart () |
| Derived classes call this method to start the clock for 'trainingTime'. More... | |
| virtual void | TrainModel (FeatureVectorListPtr _trainExamples, bool _alreadyNormalized, bool _takeOwnership, VolConstBool &_cancelFlag, RunLog &_log) |
| Performs operations such as FeatureEncoding, and Normalization. The actual training of models occurs in the specific derived implementation of 'Model'. More... | |
| double | TrianingPrepTime () const |
| bool | ValidModel () const |
| void | WriteModelXMLFields (std::ostream &o) const |
| The "WriteXML" method in Derived classes call this method to include the parents classes fields in the XML data. More... | |
| virtual void | WriteXML (const KKStr &varName, std::ostream &o) const =0 |
Static Public Member Functions | |
| static ModelPtr | CreateAModel (ModelTypes _modelType, const KKStr &_name, const ModelParam &_param, FactoryFVProducerPtr _factoryFVProducer, VolConstBool &_cancelFlag, RunLog &_log) |
| A factory method that will instantiate the appropriate class of training model based off '_modelType'. More... | |
| static ModelTypes | ModelTypeFromStr (const KKStr &_modelingTypeStr) |
| static KKStr | ModelTypeToStr (ModelTypes _modelingType) |
Protected Member Functions | |
| void | AddErrorMsg (const KKStr &errMsg, kkint32 lineNum) |
| void | AllocatePredictionVariables () |
| void | DeAllocateSpace () |
| void | NormalizeProbabilitiesWithAMinumum (kkint32 numClasses, double *probabilities, double minProbability) |
| void | ReadXMLModelPost (RunLog &log) |
| XmlTokenPtr | ReadXMLModelToken (XmlTokenPtr t, RunLog &log) |
| Will process any tokens that belong to 'ModelParam' and return NULL ones that are not will be passed back. More... | |
| void | ReduceTrainExamples (RunLog &log) |
| Reduces the Training Images down to the size dictated by the 'examplesPerClass' parameter. More... | |
Base class to all Learning Algorithms.
Base class to be used by all Learning Algorithm Models. The idea is that all learning algorithms all follow the same basic flow. The two obvious functions that they all support are Training from supplied labeled examples(List of FeatureVector objects), Prediction of an unlabeled example.
| typedef Model* KKMLL::Model::ModelPtr |
|
strong |
| Model::Model | ( | ) |
Definition at line 43 of file Model.cpp.
References alreadyNormalized, classes, classesIndex, classProbs, crossClassProbTable, crossClassProbTableSize, encoder, factoryFVProducer, fileDesc, KKB::KKStr::KKStr(), normParms, numOfClasses, param, rootFileName, trainExamples, validModel, votes, and weOwnTrainExamples.
Referenced by KKMLL::ModelDual::ModelDual(), KKMLL::ModelKnn::ModelKnn(), KKMLL::ModelOldSVM::ModelOldSVM(), KKMLL::ModelSvmBase::ModelSvmBase(), and KKMLL::ModelUsfCasCor::ModelUsfCasCor().
| Model::Model | ( | FactoryFVProducerPtr | _factoryFVProducer | ) |
Use this when you are planning on creating a empty model without parameters.
Definition at line 117 of file Model.cpp.
References alreadyNormalized, classes, classesIndex, classProbs, crossClassProbTable, crossClassProbTableSize, encoder, factoryFVProducer, KKMLL::FactoryFVProducer::FileDesc(), fileDesc, KKB::KKStr::KKStr(), normParms, numOfClasses, param, rootFileName, trainExamples, validModel, votes, and weOwnTrainExamples.
Referenced by KKMLL::ModelDual::ModelDual(), KKMLL::ModelKnn::ModelKnn(), KKMLL::ModelOldSVM::ModelOldSVM(), KKMLL::ModelSvmBase::ModelSvmBase(), and KKMLL::ModelUsfCasCor::ModelUsfCasCor().
| Model::Model | ( | const KKStr & | _name, |
| const ModelParam & | _param, | ||
| FactoryFVProducerPtr | _factoryFVProducer | ||
| ) |
Construct a instance of 'Model' using the parameters specified in '_param'.
Creates a new svm model from the provided example data.
| [in] | _name | Name of training model. |
| [in] | _param | Parameters for learning algorithm; we will create a duplicate copy. |
| [in] | _fileDesc | Description of the dataset that will be used to train the classifier and examples that will be classified. |
| [in] | _cancelFlag | Will monitor; if at any point it turns true this instance is to terminate and return to caller. |
| [in,out] | _log | Logging file. |
| [in] | _name | |
| [in] | _param | Will make own local copy. |
| [in] | _fileDesc | A description of the data file. |
| [in] | _log | A log-file stream. All important events will be output to this stream |
Definition at line 152 of file Model.cpp.
References alreadyNormalized, classes, classesIndex, classProbs, crossClassProbTable, crossClassProbTableSize, KKMLL::ModelParam::Duplicate(), encoder, factoryFVProducer, KKMLL::FactoryFVProducer::FileDesc(), fileDesc, KKB::KKStr::KKStr(), normParms, numOfClasses, param, rootFileName, trainExamples, validModel, votes, and weOwnTrainExamples.
Referenced by KKMLL::ModelDual::ModelDual(), KKMLL::ModelKnn::ModelKnn(), KKMLL::ModelOldSVM::ModelOldSVM(), KKMLL::ModelSvmBase::ModelSvmBase(), and KKMLL::ModelUsfCasCor::ModelUsfCasCor().
| Model::Model | ( | const Model & | _madel | ) |
Copy Constructor.
Definition at line 69 of file Model.cpp.
References AllocatePredictionVariables(), alreadyNormalized, classes, classesIndex, classProbs, crossClassProbTable, crossClassProbTableSize, KKMLL::ModelParam::Duplicate(), encoder, factoryFVProducer, KKMLL::FeatureEncoder2::FeatureEncoder2(), fileDesc, KKB::KKStr::KKStr(), KKMLL::MLClassIndexList::MLClassIndexList(), KKMLL::MLClassList::MLClassList(), normParms, numOfClasses, param, rootFileName, trainExamples, validModel, votes, and weOwnTrainExamples.
Referenced by KKMLL::ModelDual::ModelDual(), KKMLL::ModelKnn::ModelKnn(), KKMLL::ModelOldSVM::ModelOldSVM(), KKMLL::ModelSvmBase::ModelSvmBase(), and KKMLL::ModelUsfCasCor::ModelUsfCasCor().
|
virtual |
Frees any memory allocated by, and owned by the Model.
Definition at line 188 of file Model.cpp.
References classes, classesIndex, DeAllocateSpace(), encoder, normParms, param, trainExamples, and weOwnTrainExamples.
Definition at line 239 of file Model.cpp.
Referenced by KKMLL::ModelKnn::ReadXML(), KKMLL::ModelUsfCasCor::ReadXML(), KKMLL::ModelSvmBase::ReadXML(), KKMLL::ModelDual::ReadXML(), KKMLL::ModelOldSVM::ReadXML(), ReadXMLModelPost(), and ReadXMLModelToken().
|
protected |
Definition at line 343 of file Model.cpp.
References classes, classProbs, crossClassProbTable, crossClassProbTableSize, DeAllocateSpace(), numOfClasses, validModel, and votes.
Referenced by Model(), and TrainModel().
|
inline |
|
static |
A factory method that will instantiate the appropriate class of training model based off '_modelType'.
This method is used to construct a model that is going to be built from training data.
| [in] | _modelType | Type of model to be created; ex: mtOldSVM, mtSvmBase, or mtKNN. |
| [in] | _name | |
| [in] | _param | Parameters used to drive the creating of the model. |
| [in] | _fileDesc | Description of the dataset that will be used to train the classifier and examples that will be classified. |
| [in] | _cancelFlag | Will monitor; if at any point it turns true this instance is to terminate and return to caller. |
| [in,out] | _log | Logging file. |
| _param | Will make a duplicate copy of |
Definition at line 287 of file Model.cpp.
References KKB::KKStr::Concat(), Dual, KKB::KKException::KKException(), KNN, KKMLL::ModelDual::ModelDual(), KKMLL::ModelKnn::ModelKnn(), KKMLL::ModelOldSVM::ModelOldSVM(), KKMLL::ModelSvmBase::ModelSvmBase(), KKMLL::ModelUsfCasCor::ModelUsfCasCor(), OldSVM, KKB::KKStr::operator+(), KKB::operator+(), KKB::StrFromInt16(), KKMLL::ModelOldSVM::SupportVectorNames(), SvmBase, and UsfCasCor.
Referenced by KKMLL::TrainingProcess2::CreateModelsFromTrainingData().
|
protected |
Definition at line 383 of file Model.cpp.
References classProbs, crossClassProbTable, numOfClasses, and votes.
Referenced by AllocatePredictionVariables(), and ~Model().
|
virtual |
Return short user readable description of model.
Reimplemented in KKMLL::ModelDual, KKMLL::ModelOldSVM, and KKMLL::ModelSvmBase.
Definition at line 248 of file Model.cpp.
References ModelTypeStr(), Name(), and KKB::KKStr::operator+().
Referenced by KKMLL::TrainingProcess2::ModelDescription(), and ProbabilitiesByClassDual().
|
pure virtual |
Implemented in KKMLL::ModelDual, KKMLL::ModelOldSVM, KKMLL::ModelUsfCasCor, KKMLL::ModelSvmBase, and KKMLL::ModelKnn.
| const FeatureEncoder2 & Model::Encoder | ( | ) | const |
Definition at line 406 of file Model.cpp.
References encoder, and KKB::KKException::KKException().
|
inline |
|
virtual |
Reimplemented in KKMLL::ModelOldSVM.
Definition at line 415 of file Model.cpp.
References KKB::KKException::KKException(), param, and KKMLL::ModelParam::SelectedFeatures().
|
virtual |
Reimplemented in KKMLL::ModelDual, KKMLL::ModelOldSVM, KKMLL::ModelSvmBase, and KKMLL::ModelUsfCasCor.
Definition at line 208 of file Model.cpp.
References classes, classesIndex, classProbs, crossClassProbTable, encoder, KKMLL::FeatureEncoder2::MemoryConsumedEstimated(), KKMLL::ModelParam::MemoryConsumedEstimated(), KKMLL::NormalizationParms::MemoryConsumedEstimated(), KKMLL::MLClassList::MemoryConsumedEstimated(), KKB::KKStr::MemoryConsumedEstimated(), KKMLL::FeatureVectorList::MemoryConsumedEstimated(), KKMLL::MLClassIndexList::MemoryConsumedEstimated(), normParms, numOfClasses, param, rootFileName, trainExamples, votes, and weOwnTrainExamples.
Referenced by KKMLL::ModelSvmBase::MemoryConsumedEstimated(), KKMLL::ModelUsfCasCor::MemoryConsumedEstimated(), KKMLL::ModelOldSVM::MemoryConsumedEstimated(), KKMLL::ModelDual::MemoryConsumedEstimated(), and KKMLL::TrainingProcess2::MemoryConsumedEstimated().
|
inline |
Definition at line 170 of file Model.h.
References classes.
Referenced by KKMLL::TrainingProcess2::ReadXML().
| MLClassListPtr Model::MLClassesNewInstance | ( | ) | const |
Returns a new instances of 'classes' by calling copy constructor.
Definition at line 228 of file Model.cpp.
References classes, and KKMLL::MLClassList::MLClassList().
Referenced by KKMLL::TrainingProcess2::CreateModelsFromTrainingData().
|
pure virtual |
Implemented in KKMLL::ModelDual, KKMLL::ModelOldSVM, KKMLL::ModelSvmBase, KKMLL::ModelUsfCasCor, and KKMLL::ModelKnn.
Referenced by KKMLL::Classifier2::Classifier2(), KKMLL::TrainingProcess2::ModelType(), ModelTypeStr(), KKMLL::TrainingProcess2::OldSVMModel(), ReadXMLModelToken(), KKMLL::TrainingProcess2::TrainingProcessLeft(), and KKMLL::TrainingProcess2::TrainingProcessRight().
|
static |
Definition at line 271 of file Model.cpp.
References Dual, KKB::KKStr::EqualIgnoreCase(), KNN, Null, OldSVM, SvmBase, and UsfCasCor.
Referenced by KKMLL::TrainingConfiguration2::ModelTypeFromStr(), and ReadXMLModelToken().
|
inlinevirtual |
Definition at line 176 of file Model.h.
References ModelType(), and ModelTypeToStr().
Referenced by Description(), KKMLL::TrainingProcess2::ModelTypeStr(), ReadXMLModelToken(), and WriteModelXMLFields().
|
static |
Definition at line 256 of file Model.cpp.
References Dual, KNN, Null, OldSVM, SvmBase, and UsfCasCor.
Referenced by ModelTypeStr(), KKMLL::TrainingConfiguration2::ModelTypeStr(), and KKMLL::TrainingConfiguration2::ModelTypeToStr().
|
inline |
Definition at line 178 of file Model.h.
Referenced by KKMLL::ModelSvmBase::Description(), KKMLL::ModelOldSVM::Description(), KKMLL::ModelDual::Description(), Description(), and WriteModelXMLFields().
|
inline |
|
virtual |
Return true, if nominal fields need to be normalized.
Reimplemented in KKMLL::ModelOldSVM.
Definition at line 423 of file Model.cpp.
References KKMLL::ModelParam::EncodingMethod(), KKB::KKException::KKException(), KKMLL::ModelParam::NoEncoding, and param.
|
protected |
|
inline |
Definition at line 183 of file Model.h.
References param.
Referenced by KKMLL::TrainingProcess2::Parameters().
|
pure virtual |
Implemented in KKMLL::ModelDual, KKMLL::ModelOldSVM, KKMLL::ModelUsfCasCor, KKMLL::ModelSvmBase, and KKMLL::ModelKnn.
|
pure virtual |
Implemented in KKMLL::ModelDual, KKMLL::ModelOldSVM, KKMLL::ModelUsfCasCor, KKMLL::ModelSvmBase, and KKMLL::ModelKnn.
Referenced by KKMLL::Classifier2::ClassifyAExample().
|
inlinevirtual |
Reimplemented in KKMLL::ModelOldSVM.
Definition at line 230 of file Model.h.
Referenced by KKMLL::Classifier2::PredictRaw().
|
virtual |
Every prediction method in every class that is inherited from this class should call this method before performing there prediction. Such things as Normalization and Feature Encoding.
| [in] | fv | Feature vector of example that needs to be prepared. |
| [out] | newExampleCreated | Indicates if either Feature Encoding and/or Normalization needed to be done. If neither then the original instance is returned. If Yes then a new instance which the caller will have to delete will be returned. |
| [in] | fv | Feature vector of example that needs to be prepared. |
| [out] | newExampleCreated | Indicates if either Feature Encoding and/or Normalization needed to be done. If neither then the original instance is returned. If Yes then a new instance which the caller will have to be delete will be returned. |
Reimplemented in KKMLL::ModelOldSVM.
Definition at line 574 of file Model.cpp.
References alreadyNormalized, KKMLL::FeatureEncoder2::EncodeAExample(), encoder, normParms, and KKMLL::NormalizationParms::ToNormalized().
Referenced by KKMLL::ModelSvmBase::Predict(), KKMLL::ModelUsfCasCor::Predict(), KKMLL::ModelDual::Predict(), KKMLL::ModelKnn::ProbabilitiesByClass(), KKMLL::ModelSvmBase::ProbabilitiesByClass(), KKMLL::ModelUsfCasCor::ProbabilitiesByClass(), and KKMLL::ModelDual::ProbabilitiesByClassDual().
|
pure virtual |
Implemented in KKMLL::ModelDual, KKMLL::ModelOldSVM, KKMLL::ModelUsfCasCor, KKMLL::ModelSvmBase, and KKMLL::ModelKnn.
Referenced by KKMLL::Classifier2::ProbabilitiesByClass(), and ProbabilitiesByClassDual().
|
pure virtual |
Implemented in KKMLL::ModelOldSVM, KKMLL::ModelDual, KKMLL::ModelUsfCasCor, KKMLL::ModelSvmBase, and KKMLL::ModelKnn.
|
pure virtual |
Derives predicted probabilities by class.
Will get the probabilities assigned to each class by the classifier. The '_mlClasses' parameter dictates the order of the classes. That is the probabilities for any given index in '_probabilities' will be for the class specified in the same index in '_mlClasses'.
| [in] | _example | FeatureVector object to calculate predicted probabilities for. |
| [in] | _mlClasses | List of classes that caller is aware of. This should be the same list that was used when constructing this Model object. The list must be the same but not necessarily in the same order as when Model was 1st constructed. The ordering of this list will dictate the order that '_probabilities' will be populated. |
| [out] | _probabilities | An array that must be as big as the number of classes in '_mlClasses'. The probability of class in '_mlClasses[x]' will be returned in probabilities[x]. |
Implemented in KKMLL::ModelDual, KKMLL::ModelOldSVM, KKMLL::ModelUsfCasCor, KKMLL::ModelSvmBase, and KKMLL::ModelKnn.
|
virtual |
Only applied to ModelDual classifier.
Reimplemented in KKMLL::ModelDual.
Definition at line 830 of file Model.cpp.
References KKMLL::ClassProbList::ClassProbList(), Description(), KKB::KKStr::operator=(), and ProbabilitiesByClass().
Referenced by KKMLL::Classifier2::ProbabilitiesByClassDual().
|
pure virtual |
To be implemented by derived classes; the parent classes fields will be updated by the derived class calling ReadXMLModelToken.
Implemented in KKMLL::ModelOldSVM, KKMLL::ModelDual, KKMLL::ModelSvmBase, KKMLL::ModelUsfCasCor, and KKMLL::ModelKnn.
|
protected |
Definition at line 987 of file Model.cpp.
References AddErrorMsg(), classes, KKB::KKStr::Concat(), fileDesc, param, and KKMLL::ModelParam::ValidParam().
Referenced by KKMLL::ModelKnn::ReadXML(), KKMLL::ModelUsfCasCor::ReadXML(), KKMLL::ModelSvmBase::ReadXML(), KKMLL::ModelDual::ReadXML(), and KKMLL::ModelOldSVM::ReadXML().
|
protected |
Will process any tokens that belong to 'ModelParam' and return NULL ones that are not will be passed back.
Definition at line 884 of file Model.cpp.
References AddErrorMsg(), classes, KKB::KKStr::Concat(), KKB::KKStr::EqualIgnoreCase(), KKB::KKStr::KKStr(), ModelType(), ModelTypeFromStr(), ModelTypeStr(), KKB::KKStr::operator=(), rootFileName, KKMLL::XmlElementMLClassNameList::TakeOwnership(), KKB::XmlToken::tokElement, KKB::XmlToken::TokenType(), KKB::XmlElement::ToKKStr(), KKB::XmlToken::VarName(), and KKB::XmlElement::VarName().
Referenced by KKMLL::ModelKnn::ReadXML(), KKMLL::ModelUsfCasCor::ReadXML(), KKMLL::ModelSvmBase::ReadXML(), KKMLL::ModelDual::ReadXML(), and KKMLL::ModelOldSVM::ReadXML().
|
protected |
Reduces the Training Images down to the size dictated by the 'examplesPerClass' parameter.
Definition at line 649 of file Model.cpp.
References KKMLL::ModelParam::ExamplesPerClass(), KKMLL::FeatureVectorList::ExtractExamplesForAGivenClass(), KKMLL::FeatureVectorList::GetClassStatistics(), KKMLL::FeatureVectorList::ManufactureEmptyList(), param, trainExamples, validModel, and weOwnTrainExamples.
Referenced by TrainModel().
|
virtual |
| crossProbTable | two dimension matrix that needs to be classes.QueueSize () squared. |
Reimplemented in KKMLL::ModelOldSVM, KKMLL::ModelDual, and KKMLL::ModelSvmBase.
Definition at line 755 of file Model.cpp.
References crossClassProbTable.
Referenced by KKMLL::Classifier2::RetrieveCrossProbTable().
|
inline |
|
inline |
|
virtual |
Definition at line 436 of file Model.cpp.
References KKB::KKException::KKException(), param, and KKMLL::ModelParam::SelectedFeatures().
Referenced by KKMLL::ModelUsfCasCor::TrainModel().
|
inline |
|
inline |
Definition at line 191 of file Model.h.
Referenced by KKMLL::TrainingProcess2::TrainingTime().
| void Model::TrainingTimeEnd | ( | ) |
Derived classes call this method to stop the clock for 'trainingTime'.
Definition at line 452 of file Model.cpp.
References KKB::osGetSystemTimeUsed().
Referenced by KKMLL::ModelUsfCasCor::TrainModel(), KKMLL::ModelSvmBase::TrainModel(), KKMLL::ModelDual::TrainModel(), and KKMLL::ModelOldSVM::TrainModel().
| void Model::TrainingTimeStart | ( | ) |
Derived classes call this method to start the clock for 'trainingTime'.
Definition at line 445 of file Model.cpp.
References KKB::osGetSystemTimeUsed().
Referenced by KKMLL::ModelUsfCasCor::TrainModel(), KKMLL::ModelSvmBase::TrainModel(), KKMLL::ModelDual::TrainModel(), and KKMLL::ModelOldSVM::TrainModel().
|
virtual |
Performs operations such as FeatureEncoding, and Normalization. The actual training of models occurs in the specific derived implementation of 'Model'.
Performs operations such as FeatureEncoding, and Normalization; the actual training of models occurs in the specific implementation of 'Model'.
| [in] | _trainExamples | Training data that classifier will be built from. If the examples need to be normalized or encoded and we are not taking ownership then a duplicate list of examples will be created that this method and class will be free to modify. |
| [in] | _alreadyNormalized | Indicates if contents of '_trainExamples' are normalized already; if not they will be normalized. |
| [in] | _takeOwnership | This instance of Model will take ownership of '_examples' and is free to modify its contents. |
| _takeOwnership | True = Model will take ownership of these examples |
Reimplemented in KKMLL::ModelOldSVM, KKMLL::ModelDual, KKMLL::ModelSvmBase, KKMLL::ModelUsfCasCor, and KKMLL::ModelKnn.
Definition at line 467 of file Model.cpp.
References AllocatePredictionVariables(), alreadyNormalized, classes, classesIndex, KKB::KKStr::Concat(), KKMLL::FeatureVectorList::Duplicate(), KKMLL::FeatureEncoder2::EncodeAllExamples(), encoder, KKMLL::ModelParam::EncodingMethod(), KKMLL::ModelParam::ExamplesPerClass(), KKMLL::FeatureVectorList::ExtractListOfClasses(), KKMLL::FeatureEncoder2::FeatureEncoder2(), fileDesc, KKB::KKException::KKException(), KKMLL::MLClassIndexList::MLClassIndexList(), KKMLL::ModelParam::NoEncoding, KKMLL::NormalizationParms::NormalizationParms(), KKMLL::NormalizationParms::NormalizeExamples(), normParms, KKMLL::ModelParam::Null, KKB::osGetSystemTimeUsed(), param, ReduceTrainExamples(), KKMLL::MLClassList::SortByName(), trainExamples, and weOwnTrainExamples.
Referenced by KKMLL::TrainingProcess2::CreateModelsFromTrainingData(), KKMLL::ModelKnn::TrainModel(), KKMLL::ModelUsfCasCor::TrainModel(), KKMLL::ModelSvmBase::TrainModel(), KKMLL::ModelDual::TrainModel(), and KKMLL::ModelOldSVM::TrainModel().
|
inline |
|
inline |
Definition at line 195 of file Model.h.
References validModel.
Referenced by KKMLL::Classifier2::Classifier2(), KKMLL::TrainingProcess2::CreateModelsFromTrainingData(), and KKMLL::TrainingProcess2::ReadXML().
| void Model::WriteModelXMLFields | ( | std::ostream & | o | ) | const |
The "WriteXML" method in Derived classes call this method to include the parents classes fields in the XML data.
Definition at line 854 of file Model.cpp.
References alreadyNormalized, classes, classesIndex, fileDesc, ModelTypeStr(), Name(), normParms, param, rootFileName, KKMLL::NormalizationParms::WriteXML(), KKMLL::ModelParam::WriteXML(), KKMLL::FileDesc::WriteXML(), KKB::XmlElementBool::WriteXML(), KKMLL::MLClassIndexList::WriteXML(), KKB::KKStr::WriteXML(), KKMLL::XmlElementMLClassNameList::WriteXML(), and KKB::DateTime::YYYY_MM_DD_HH_MM_SS().
Referenced by KKMLL::ModelKnn::WriteXML(), KKMLL::ModelUsfCasCor::WriteXML(), KKMLL::ModelSvmBase::WriteXML(), KKMLL::ModelDual::WriteXML(), and KKMLL::ModelOldSVM::WriteXML().
|
pure virtual |
Implemented in KKMLL::ModelOldSVM.
Referenced by KKMLL::TrainingProcess2::WriteXML().
|
protected |
Definition at line 388 of file Model.h.
Referenced by AlreadyNormalized(), Model(), KKMLL::ModelOldSVM::PrepExampleForPrediction(), PrepExampleForPrediction(), TrainModel(), and WriteModelXMLFields().
|
protected |
Definition at line 390 of file Model.h.
Referenced by AllocatePredictionVariables(), MemoryConsumedEstimated(), MLClasses(), MLClassesNewInstance(), Model(), KKMLL::ModelUsfCasCor::Predict(), KKMLL::ModelOldSVM::ProbabilitiesByClass(), ReadXMLModelPost(), ReadXMLModelToken(), KKMLL::ModelOldSVM::TrainModel(), TrainModel(), WriteModelXMLFields(), and ~Model().
|
protected |
Definition at line 392 of file Model.h.
Referenced by MemoryConsumedEstimated(), Model(), KKMLL::ModelSvmBase::Predict(), KKMLL::ModelKnn::ProbabilitiesByClass(), KKMLL::ModelSvmBase::ProbabilitiesByClass(), KKMLL::ModelSvmBase::RetrieveCrossProbTable(), TrainModel(), WriteModelXMLFields(), and ~Model().
|
protected |
Definition at line 394 of file Model.h.
Referenced by AllocatePredictionVariables(), DeAllocateSpace(), MemoryConsumedEstimated(), Model(), KKMLL::ModelSvmBase::Predict(), KKMLL::ModelSvmBase::ProbabilitiesByClass(), and KKMLL::ModelOldSVM::ProbabilitiesByClass().
|
protected |
Probabilities between Binary Classes From last Prediction
Definition at line 396 of file Model.h.
Referenced by AllocatePredictionVariables(), DeAllocateSpace(), MemoryConsumedEstimated(), Model(), and RetrieveCrossProbTable().
|
protected |
Definition at line 398 of file Model.h.
Referenced by AllocatePredictionVariables(), and Model().
|
protected |
Definition at line 400 of file Model.h.
Referenced by Encoder(), MemoryConsumedEstimated(), Model(), PrepExampleForPrediction(), TrainModel(), and ~Model().
|
protected |
|
protected |
Definition at line 404 of file Model.h.
Referenced by FactoryFVProducer(), Model(), and KKMLL::ModelDual::TrainModel().
|
protected |
Definition at line 406 of file Model.h.
Referenced by Model(), KKMLL::ModelSvmBase::ModelSvmBase(), ReadXMLModelPost(), KKMLL::ModelOldSVM::TrainModel(), TrainModel(), and WriteModelXMLFields().
|
protected |
Definition at line 408 of file Model.h.
Referenced by MemoryConsumedEstimated(), Model(), KKMLL::ModelOldSVM::PrepExampleForPrediction(), PrepExampleForPrediction(), TrainModel(), WriteModelXMLFields(), and ~Model().
|
protected |
Number of Classes defined in crossClassProbTable.
Definition at line 410 of file Model.h.
Referenced by AllocatePredictionVariables(), DeAllocateSpace(), MemoryConsumedEstimated(), Model(), KKMLL::ModelSvmBase::Predict(), KKMLL::ModelKnn::ProbabilitiesByClass(), KKMLL::ModelSvmBase::ProbabilitiesByClass(), KKMLL::ModelOldSVM::ProbabilitiesByClass(), and KKMLL::ModelSvmBase::RetrieveCrossProbTable().
|
protected |
Will own this instance,
Definition at line 412 of file Model.h.
Referenced by GetFeatureNums(), MemoryConsumedEstimated(), Model(), KKMLL::ModelDual::ModelDual(), KKMLL::ModelKnn::ModelKnn(), KKMLL::ModelOldSVM::ModelOldSVM(), KKMLL::ModelSvmBase::ModelSvmBase(), KKMLL::ModelUsfCasCor::ModelUsfCasCor(), NormalizeNominalAttributes(), KKMLL::ModelOldSVM::Param(), Param(), KKMLL::ModelKnn::ReadXML(), KKMLL::ModelUsfCasCor::ReadXML(), KKMLL::ModelSvmBase::ReadXML(), KKMLL::ModelDual::ReadXML(), KKMLL::ModelOldSVM::ReadXML(), ReadXMLModelPost(), ReduceTrainExamples(), SelectedFeatures(), TrainModel(), WriteModelXMLFields(), and ~Model().
|
protected |
This is the root name to be used by all component objects; such as svm_model, mlClasses, and svmParam(including selected features). Each one will have the same rootName with a different suffix.
Definition at line 414 of file Model.h.
Referenced by MemoryConsumedEstimated(), Model(), ReadXMLModelToken(), RootFileName(), KKMLL::ModelSvmBase::TrainModel(), and WriteModelXMLFields().
|
protected |
Definition at line 424 of file Model.h.
Referenced by MemoryConsumedEstimated(), Model(), ReduceTrainExamples(), KKMLL::ModelUsfCasCor::TrainModel(), KKMLL::ModelSvmBase::TrainModel(), KKMLL::ModelDual::TrainModel(), KKMLL::ModelOldSVM::TrainModel(), TrainModel(), and ~Model().
|
protected |
Definition at line 426 of file Model.h.
Referenced by AllocatePredictionVariables(), Model(), KKMLL::ModelDual::ReadXML(), ReduceTrainExamples(), KKMLL::ModelKnn::TrainModel(), KKMLL::ModelUsfCasCor::TrainModel(), KKMLL::ModelSvmBase::TrainModel(), KKMLL::ModelDual::TrainModel(), KKMLL::ModelOldSVM::TrainModel(), and ValidModel().
|
protected |
Definition at line 428 of file Model.h.
Referenced by AllocatePredictionVariables(), DeAllocateSpace(), MemoryConsumedEstimated(), Model(), KKMLL::ModelSvmBase::Predict(), KKMLL::ModelSvmBase::ProbabilitiesByClass(), and KKMLL::ModelOldSVM::ProbabilitiesByClass().
|
protected |
Indicates if we own the 'trainExamples'. This does not mean that we own its contents. That is determined by 'trainExamples->Owner ()'.
Definition at line 430 of file Model.h.
Referenced by MemoryConsumedEstimated(), Model(), ReduceTrainExamples(), KKMLL::ModelOldSVM::TrainModel(), TrainModel(), and ~Model().