22 #if !defined(_CLASSPROB_) 29 #if !defined(_FEATUREENCODER2_) 43 #if !defined(_FEATUREVECTOR_) 51 #if !defined(_FileDesc_Defined_) 57 #if !defined(_MLCLASS_) 67 #if !defined(_NORMALIZATIONPARMS_) 74 #if !defined(_FactoryFVProducer_Defined_) 226 bool& newExampleCreated
231 MLClassPtr & predClass,
250 MLClassPtr knownClass,
251 MLClassPtr& predClass1,
252 MLClassPtr& predClass2,
255 double& probOfKnownClass,
256 double& predClass1Prob,
257 double& predClass2Prob,
259 bool& knownClassOneOfTheWinners,
274 KKStr& classifier1Desc,
275 KKStr& classifier2Desc,
286 double* _probabilities,
309 double* _probabilities,
316 double** crossProbTable,
333 bool _alreadyNormalized,
373 double* probabilities,
374 double minProbability
436 double trianingPrepTime;
438 double trainingTimeStart;
445 #define _Model_Defined_ 484 template<
class ModelType>
const KKStr & Name() const
ModelType * Value() const
Base class to all Learning Algorithms.
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
Provides a detailed description of the attributes of a dataset.
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'...
void Name(const KKStr &_name)
Maintains a list of classes and their associated integer index.
FeatureVector * FeatureVectorPtr
static KKStr ModelTypeToStr(ModelTypes _modelingType)
XmlElement(XmlTagPtr _nameTag, XmlStream &s, RunLog &log)
virtual void WriteXML(const KKStr &varName, std::ostream &o) const =0
NormalizationParmsPtr normParms
NormalizationParms * NormalizationParmsPtr
XmlTokenPtr ReadXMLModelToken(XmlTokenPtr t, RunLog &log)
Will process any tokens that belong to 'ModelParam' and return NULL ones that are not will be passed ...
virtual FeatureNumListConstPtr GetFeatureNums() const
FeatureVectorListPtr trainExamples
XmlElementModelTemplate(XmlTagPtr tag, XmlStream &s, VolConstBool &cancelFlag, RunLog &log)
Represents a "Class" in the Machine Learning Sense.
void AddErrorMsg(const KKStr &errMsg, kkint32 lineNum)
virtual ~XmlElementModelTemplate()
void WriteModelXMLFields(std::ostream &o) const
The "WriteXML" method in Derived classes call this method to include the parents classes fields in th...
FactoryFVProducerPtr factoryFVProducer
double TrianingPrepTime() const
virtual void PredictRaw(FeatureVectorPtr example, MLClassPtr &predClass, double &dist)
static ModelTypes ModelTypeFromStr(const KKStr &_modelingTypeStr)
XmlElementModel(XmlTagPtr tag, XmlStream &s, RunLog &log)
virtual ModelPtr Duplicate() const =0
virtual FeatureVectorPtr PrepExampleForPrediction(FeatureVectorPtr fv, bool &newExampleCreated)
Every prediction method in every class that is inherited from this class should call this method befo...
const KKB::DateTime & TimeSaved() const
Container class for FeatureVector derived objects.
const KKStr & RootFileName() const
virtual void ProbabilitiesByClass(FeatureVectorPtr example, const MLClassList &_mlClasses, kkint32 *_votes, double *_probabilities, RunLog &_log)=0
Used to record probability for a specified class; and a list of classes.
bool AlreadyNormalized() const
XmlTag const * XmlTagConstPtr
#define _FeatureNumList_Defined_
Manages the reading and writing of objects in a simple XML format. For a class to be supported by Xml...
FactoryFVProducerPtr FactoryFVProducer() const
void TrainingTimeEnd()
Derived classes call this method to stop the clock for 'trainingTime'.
virtual kkint32 MemoryConsumedEstimated() const
ModelParamPtr Param() const
static KKStr Concat(const std::vector< std::string > &values)
Concatenates the list of 'std::string' strings.
ClassProbList * ClassProbListPtr
The base class to be used for the manufacturing if "Model" derived classes.
virtual bool NormalizeNominalAttributes() const
virtual void RetrieveCrossProbTable(MLClassList &classes, double **crossProbTable, RunLog &log)
void NormalizeProbabilitiesWithAMinumum(kkint32 numClasses, double *probabilities, double minProbability)
virtual void ProbabilitiesByClassDual(FeatureVectorPtr example, KKStr &classifier1Desc, KKStr &classifier2Desc, ClassProbListPtr &classifier1Results, ClassProbListPtr &classifier2Results, RunLog &log)
Only applied to ModelDual classifier.
Model(const KKStr &_name, const ModelParam &_param, FactoryFVProducerPtr _factoryFVProducer)
Construct a instance of 'Model' using the parameters specified in '_param'.
void ReduceTrainExamples(RunLog &log)
Reduces the Training Images down to the size dictated by the 'examplesPerClass' parameter.
MLClassListPtr MLClasses() const
virtual ClassProbListPtr ProbabilitiesByClass(FeatureVectorPtr example, RunLog &log)=0
virtual ModelTypes ModelType() const =0
double ** crossClassProbTable
virtual KKStr ModelTypeStr() const
virtual ~XmlElementModel()
virtual MLClassPtr Predict(FeatureVectorPtr example, RunLog &log)=0
Normalization Parameters; calculation and implementation.
FeatureNumListConst * FeatureNumListConstPtr
KKStr & operator=(const KKStr &src)
Used for logging messages.
void EncodeProblem(const struct svm_paramater ¶m, struct svm_problem &prob_in, struct svm_problem &prob_out)
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 ...
FeatureEncoder2 * FeatureEncoder2Ptr
double TrainingTime() const
void TrainingTimeStart()
Derived classes call this method to start the clock for 'trainingTime'.
const FeatureEncoder2 & Encoder() const
void ReadXMLModelPost(RunLog &log)
virtual ~Model()
Frees any memory allocated by, and owned by the Model.
Responsible for creating a FeatureFectorProducer instance.
void RootFileName(const KKStr &_rootFileName)
Model(const Model &_madel)
Copy Constructor.
XmlElementModel * XmlElementModelPtr
kkint32 crossClassProbTableSize
Maintains a list of MLClass instances.
FeatureVectorList * FeatureVectorListPtr
virtual void ProbabilitiesByClass(FeatureVectorPtr _example, const MLClassList &_mlClasses, double *_probabilities, RunLog &_log)=0
Derives predicted probabilities by class.
Represents a Feature Vector of a single example, labeled or unlabeled.
FeatureEncoder2Ptr encoder
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 ...
virtual KKStr Description() const
Abstract Base class for Machine Learning parameters.
MLClassIndexListPtr classesIndex
FactoryFVProducer * FactoryFVProducerPtr
ModelType * TakeOwnership()
Model(FactoryFVProducerPtr _factoryFVProducer)
Use this when you are planning on creating a empty model without parameters.
void AllocatePredictionVariables()
MLClassListPtr MLClassesNewInstance() const
virtual FeatureNumListConstPtr SelectedFeatures() const
volatile const bool VolConstBool