KSquare Utilities
KKMLL Namespace Reference

Namespace for all K^2 Machine Learning code. More...

Classes

class  Attribute
 describes a single Feature, Type and possible values. More...
 
class  AttributeList
 
class  AttributeTypeVector
 
class  BinaryClassParms
 Similar to SVMparam except it is specialized for two classes. More...
 
class  BinaryClassParmsList
 
class  ClassAssignments
 Binds MLClass objects to the appropriate number that the Learning Algorithm expects. More...
 
class  ClassificationBiasMatrix
 Assists in adjusting a Classifiers output for bias of a classifier. More...
 
class  Classifier2
 
class  Classifier2List
 
class  ClassProb
 Used to record probability for a specified class; and a list of classes. More...
 
class  ClassProbList
 
class  ClassStatistic
 Used by routines that retrieve Class statistics from FeatureVectorList instances. More...
 
class  ClassStatisticList
 
class  ConfusionMatrix2
 A confusion matrix object that is used to record the results from a CrossValidation. <see also cref="CrossValidation" More...
 
class  ConfussionMatrix2List
 
class  CrossValidation
 A class that is meant to manage a n-Fold Cross Validation. More...
 
class  CrossValidationMxN
 
class  CrossValidationVoting
 
class  DuplicateImage
 
class  DuplicateImageList
 
class  DuplicateImages
 Detects duplicate images in a given FeaureVectorList objects. More...
 
class  ExtractExampleFileName
 
class  ExtractFeatureData
 
class  FactoryFVProducer
 Responsible for creating a FeatureFectorProducer instance. More...
 
class  FeatureEncoder
 
class  FeatureEncoder2
 
class  FeatureFileIO
 Base class for all FeatureFileIO classes. More...
 
class  FeatureFileIOArff
 Support the writing of ARFF Formatted Feature Files. More...
 
class  FeatureFileIOC45
 Supports the reading and writing of feature data from C45 formated feature files. More...
 
class  FeatureFileIOColumn
 Supports a simple Feature File format where each column represents a example and each row a feature value. More...
 
class  FeatureFileIODstWeb
 
class  FeatureFileIORoberts
 Supports the writing of Feature Data to a file that can then be read by OpenDT. More...
 
class  FeatureFileIOSparse
 Supports the reading and writing of Sparse feature files similar to the ones libSVM use. More...
 
class  FeatureFileIOUCI
 Supports the reading and writing of Feature data from a file format commonly used by many dataset's in the UCI repository. More...
 
class  FeatureNumList
 Keeps track of selected features. More...
 
class  FeatureVector
 Represents a Feature Vector of a single example, labeled or unlabeled. More...
 
class  FeatureVectorList
 Container class for FeatureVector derived objects. More...
 
class  FeatureVectorProducer
 A abstract class that is meant to compute a FeatureVector from a source image. More...
 
class  FileDesc
 Provides a detailed description of the attributes of a dataset. More...
 
class  FileDescList
 Container class file 'FileDesc' instances. More...
 
class  GrayScaleImagesFV
 Specialized version of KKMLL::FeatureVector that will be used to represent the features of a Shrimp. More...
 
class  GrayScaleImagesFVList
 
class  GrayScaleImagesFVProducer
 
class  GrayScaleImagesFVProducerFactory
 
class  ImageDataTreeEntry
 
class  ImageFeaturesDataIndexed
 
class  ImageFeaturesNameIndexed
 
class  ImageFeaturesNodeKey
 
class  KKMLVariables
 
class  MLClass
 Represents a "Class" in the Machine Learning Sense. More...
 
class  MLClassIndexList
 Maintains a list of classes and their associated integer index. More...
 
class  MLClassList
 Maintains a list of MLClass instances. More...
 
class  Model
 Base class to all Learning Algorithms. More...
 
class  ModelDual
 Will implement the Dual Classifier Model. More...
 
class  ModelKnn
 
class  ModelOldSVM
 A specialization of 'Model'; meant to Wrap the original version of 'SvmModel' class. It will allow us to use the original implementation using version 2.39 of LibSVM. More...
 
class  ModelParam
 Abstract Base class for Machine Learning parameters. More...
 
class  ModelParamDual
 
class  ModelParamKnn
 
class  ModelParamOldSVM
 
class  ModelParamSvmBase
 
class  ModelParamUsfCasCor
 This class encapsulates are the information necessary to build a UsfCasCor class. More...
 
class  ModelSvmBase
 
class  ModelUsfCasCor
 
class  NormalizationParms
 Normalization Parameters; calculation and implementation. More...
 
class  Orderings
 Used to maintain multiple orderings of a single list of FeatureVector objects. More...
 
class  ProbNamePair
 
class  SizeDistribution
 Used to keep track of examples by size; typically used by 'CrossValidation'; for each example predicted it would call the ;Increment' method keeping track. More...
 
class  SVMModel
 
class  SVMparam
 This class encapsulates are the information necessary to build a SVMModel class. More...
 
class  TrainingClass
 Specify where training examples and other related data for a MLClass that is needed to train a classifier. More...
 
class  TrainingClassList
 
class  TrainingConfiguration2
 
class  TrainingConfiguration2List
 
class  TrainingProcess2
 
class  TrainingProcess2List
 
class  XmlElementFileDesc
 
class  XmlElementMLClass
 
class  XmlElementMLClassNameList
 Will only write the ClassName rather than complete MLClass instances. More...
 
class  XmlElementModel
 The base class to be used for the manufacturing if "Model" derived classes. More...
 
class  XmlElementModelParam
 Base class to be used by all ModelParam derived objects. More...
 
class  XmlElementModelParamTemplate
 ModelParam derived classes will implement their "XmlElement" helper class via this template. More...
 
class  XmlElementModelTemplate
 

Typedefs

typedef AttributeList const * AttributeListConstPtr
 
typedef AttributeListAttributeListPtr
 
typedef AttributeAttributePtr
 
typedef AttributeTypeVectorAttributeTypeVectorPtr
 
typedef BinaryClassParmsList::BinaryClassParmsListPtr BinaryClassParmsListPtr
 
typedef BinaryClassParms::BinaryClassParmsPtr BinaryClassParmsPtr
 
typedef ClassAssignmentsClassAssignmentsPtr
 
typedef ClassificationBiasMatrix::ClassificationBiasMatrixPtr ClassificationBiasMatrixPtr
 
typedef Classifier2ListClassifier2ListPtr
 
typedef Classifier2Classifier2Ptr
 
typedef ClassProbListClassProbListPtr
 
typedef ClassProbClassProbPtr
 
typedef ClassStatisticListClassStatisticListPtr
 
typedef ClassStatisticClassStatisticPtr
 
typedef ConfusionMatrix2::ConfusionMatrix2Ptr ConfusionMatrix2Ptr
 
typedef ConfussionMatrix2ListConfussionMatrix2ListPtr
 
typedef CrossValidationCrossValidationPtr
 
typedef CrossValidationVotingCrossValidationVotingPtr
 
typedef DuplicateImageListDuplicateImageListPtr
 
typedef DuplicateImageDuplicateImagePtr
 
typedef DuplicateImagesDuplicateImagesPtr
 
typedef std::vector< double > Dvector
 
typedef FactoryFVProducerFactoryFVProducerPtr
 
typedef FeatureEncoder2FeatureEncoder2Ptr
 
typedef FeatureEncoderFeatureEncoderPtr
 
typedef FeatureFileIOC45::FeatureFileIOC45Ptr FeatureFileIOC45Ptr
 
typedef FeatureFileIOFeatureFileIOPtr
 
typedef FeatureNumList const FeatureNumListConst
 
typedef FeatureNumListConstFeatureNumListConstPtr
 
typedef FeatureNumListFeatureNumListPtr
 
typedef FeatureVectorListFeatureVectorListPtr
 
typedef FeatureVectorProducerFeatureVectorProducerPtr
 
typedef FeatureVectorFeatureVectorPtr
 
typedef FeWhatToDoFeWhatToDoPtr
 
typedef FileDesc::FileDescConstPtr FileDescConstPtr
 
typedef FileDescListFileDescListPtr
 
typedef FileDescFileDescPtr
 
typedef std::vector< float > Fvector
 
typedef GrayScaleImagesFVList::GrayScaleImagesFVListPtr GrayScaleImagesFVListPtr
 
typedef GrayScaleImagesFVProducerGrayScaleImagesFVProducerPtr
 
typedef GrayScaleImagesFV::GrayScaleImagesFVPtr GrayScaleImagesFVPtr
 
typedef ImageFeaturesDataIndexedImageFeaturesDataIndexedPtr
 
typedef ImageFeaturesNameIndexedImageFeaturesNameIndexedPtr
 
typedef std::vector< kkint32Ivector
 
typedef MLClassIndexList::MLClassIndexListPtr MLClassIndexListPtr
 
typedef MLClassListMLClassListPtr
 
typedef MLClassMLClassPtr
 
typedef ModelDual::ModelDualPtr ModelDualPtr
 
typedef ModelKnn::ModelKnnPtr ModelKnnPtr
 
typedef ModelOldSVM::ModelOldSVMPtr ModelOldSVMPtr
 
typedef ModelParamDualModelParamDualPtr
 
typedef ModelParamKnn::ModelParamKnnPtr ModelParamKnnPtr
 
typedef ModelParamOldSVMModelParamOldSVMPtr
 
typedef ModelParam::ModelParamPtr ModelParamPtr
 
typedef ModelParamSvmBase::ModelParamSvmBasePtr ModelParamSvmBasePtr
 
typedef ModelParamUsfCasCorModelParamUsfCasCorPtr
 
typedef Model::ModelPtr ModelPtr
 
typedef ModelSvmBase::ModelSvmBasePtr ModelSvmBasePtr
 
typedef ModelUsfCasCor::ModelUsfCasCorPtr ModelUsfCasCorPtr
 
typedef NormalizationParmsNormalizationParmsPtr
 
typedef OrderingsOrderingsPtr
 
typedef RunLogRunLogPtr
 
typedef SizeDistributionSizeDistributionPtr
 
typedef SVMModelSVMModelPtr
 
typedef SVMparamSVMparamPtr
 
typedef TrainingClassListTrainingClassListPtr
 
typedef TrainingClassTrainingClassPtr
 
typedef TrainingConfiguration2::TrainingConfiguration2Const TrainingConfiguration2Const
 
typedef TrainingConfiguration2::TrainingConfiguration2ConstPtr TrainingConfiguration2ConstPtr
 
typedef TrainingConfiguration2ListTrainingConfiguration2ListPtr
 
typedef TrainingConfiguration2TrainingConfiguration2Ptr
 
typedef TrainingProcess2ListTrainingProcess2ListPtr
 
typedef TrainingProcess2TrainingProcess2Ptr
 
typedef XmlElementTemplate< AttributeXmlElementAttribute
 
typedef XmlElementTemplate< AttributeListXmlElementAttributeList
 
typedef XmlElementAttributeListXmlElementAttributeListPtr
 
typedef XmlElementAttributeXmlElementAttributePtr
 
typedef XmlElementTemplate< AttributeTypeVectorXmlElementAttributeTypeVector
 
typedef XmlElementAttributeTypeVectorXmlElementAttributeTypeVectorPtr
 
typedef XmlElementTemplate< BinaryClassParmsListXmlElementBinaryClassParmsList
 
typedef XmlElementBinaryClassParmsListXmlElementBinaryClassParmsListPtr
 
typedef XmlElementTemplate< ClassProbListXmlElementClassProbList
 
typedef XmlElementClassProbListXmlElementClassProbListPtr
 
typedef XmlElementTemplate< FeatureNumListXmlElementFeatureNumList
 
typedef XmlElementFeatureNumListXmlElementFeatureNumListPtr
 
typedef XmlElementFileDescXmlElementFileDescPtr
 
typedef XmlElementTemplate< MLClassIndexListXmlElementMLClassIndexList
 
typedef XmlElementMLClassIndexListXmlElementMLClassIndexListPtr
 
typedef XmlElementMLClassNameListXmlElementMLClassNameListPtr
 
typedef XmlElementMLClassXmlElementMLClassPtr
 
typedef XmlElementModelTemplate< ModelDualXmlElementModelDual
 
typedef XmlElementModelDualXmlElementModelDualPtr
 
typedef XmlElementModelTemplate< ModelKnnXmlElementModelKnn
 
typedef XmlElementModelKnnXmlElementModelKnnPtr
 
typedef XmlElementModelTemplate< ModelOldSVMXmlElementModelOldSVM
 
typedef XmlElementModelOldSVMXmlElementModelOldSVMPtr
 
typedef XmlElementModelParamTemplate< ModelParamDualXmlElementModelParamDual
 
typedef XmlElementModelParamDualXmlElementModelParamDualPtr
 
typedef XmlElementModelParamTemplate< ModelParamKnnXmlElementModelParamKnn
 
typedef XmlElementModelParamKnnXmlElementModelParamKnnPtr
 
typedef XmlElementModelParamTemplate< ModelParamOldSVMXmlElementModelParamOldSVM
 
typedef XmlElementModelParamOldSVMXmlElementModelParamOldSVMPtr
 
typedef XmlElementModelParamXmlElementModelParamPtr
 
typedef XmlElementModelParamTemplate< ModelParamSvmBaseXmlElementModelParamSvmBase
 
typedef XmlElementModelParamSvmBaseXmlElementModelParamSvmBasePtr
 
typedef XmlElementModelParamTemplate< ModelParamUsfCasCorXmlElementModelParamUsfCasCor
 
typedef XmlElementModelParamUsfCasCorXmlElementModelParamUsfCasCorPtr
 
typedef XmlElementModelXmlElementModelPtr
 
typedef XmlElementModelTemplate< ModelSvmBaseXmlElementModelSvmBase
 
typedef XmlElementModelSvmBaseXmlElementModelSvmBasePtr
 
typedef XmlElementModelTemplate< ModelUsfCasCorXmlElementModelUsfCasCor
 
typedef XmlElementModelUsfCasCorXmlElementModelUsfCasCorPtr
 
typedef XmlElementTemplate< NormalizationParmsXmlElementNormalizationParms
 
typedef XmlElementNormalizationParmsXmlElementNormalizationParmsPtr
 
typedef XmlElementTemplate< SVMModelXmlElementSVMModel
 
typedef XmlElementSVMModelXmlElementSVMModelPtr
 
typedef XmlElementTemplate< SVMparamXmlElementSVMparam
 
typedef XmlElementSVMparamXmlElementSVMparamPtr
 
typedef XmlElementTemplate< TrainingClassXmlElementTrainingClass
 
typedef XmlElementTemplate< TrainingClassListXmlElementTrainingClassList
 
typedef XmlElementTrainingClassListXmlElementTrainingClassListPtr
 
typedef XmlElementTrainingClassXmlElementTrainingClassPtr
 
typedef XmlElementTemplate< TrainingConfiguration2XmlElementTrainingConfiguration2
 
typedef XmlElementTrainingConfiguration2XmlElementTrainingConfiguration2Ptr
 
typedef XmlElementTemplate< TrainingProcess2XmlElementTrainingProcess2
 
typedef XmlElementTrainingProcess2XmlElementTrainingProcess2Ptr
 
typedef struct svm_nodeXSpacePtr
 

Enumerations

enum  AttributeType : int {
  AttributeType::NULLAttribute, AttributeType::Ignore, AttributeType::Numeric, AttributeType::Nominal,
  AttributeType::Ordinal, AttributeType::Symbolic
}
 
enum  FeWhatToDo { FeWhatToDo::FeAsIs, FeWhatToDo::FeBinary, FeWhatToDo::FeScale }
 
enum  LearnType {
  LearnType::NORMAL, LearnType::BAGGING, LearnType::BOOSTING, LearnType::SUBSPACE,
  LearnType::SAMPLESV
}
 
enum  SVM_EncodingMethod : int { SVM_EncodingMethod::Null, SVM_EncodingMethod::NoEncoding, SVM_EncodingMethod::Binary, SVM_EncodingMethod::Scaled }
 
enum  SVM_KernalType : int { SVM_KernalType::Null, SVM_KernalType::Linear, SVM_KernalType::Polynomial, SVM_KernalType::RBF }
 
enum  SVM_MachineType : int {
  SVM_MachineType::Null, SVM_MachineType::OneVsOne, SVM_MachineType::OneVsAll, SVM_MachineType::BinaryCombos,
  SVM_MachineType::BoostSVM
}
 
enum  SVM_SelectionMethod : int { SVM_SelectionMethod::Null, SVM_SelectionMethod::Voting, SVM_SelectionMethod::Probability }
 

Functions

AttributeType AttributeTypeFromStr (const KKStr &s)
 
const KKStrAttributeTypeToStr (AttributeType type)
 
void EncodeProblem (const struct svm_paramater &param, struct svm_problem &prob_in, struct svm_problem &prob_out)
 
SVM_EncodingMethod EncodingMethodFromStr (const KKStr &encodingMethodStr)
 
KKStr EncodingMethodToStr (SVM_EncodingMethod encodingMethod)
 
SVM_KernalType KernalTypeFromStr (const KKStr &kernalTypeStr)
 
KKStr KernalTypeToStr (SVM_KernalType kernalType)
 
SVM_MachineType MachineTypeFromStr (const KKStr &machineTypeStr)
 
KKStr MachineTypeToStr (SVM_MachineType machineType)
 
AttributeType operator++ (AttributeType zed)
 
std::ostream & operator<< (std::ostream &os, const FeatureNumList &features)
 
std::ostream & operator<< (std::ostream &os, const MLClassList &classList)
 
KKStroperator<< (KKStr &str, const MLClassList &classList)
 
KKStroperator<< (KKStr &left, TrainingConfiguration2::ModelTypes modelingMethod)
 
std::ostream & operator<< (std::ostream &os, TrainingConfiguration2::ModelTypes modelingMethod)
 
ostream & operator<< (ostream &os, const FeatureNumList &features)
 
bool PairCompareOperator (ProbNamePair l, ProbNamePair r)
 
SVM_SelectionMethod SelectionMethodFromStr (const KKStr &selectionMethodStr)
 
KKStr SelectionMethodToStr (SVM_SelectionMethod selectionMethod)
 
void SvmDestroyModel (struct SvmModel233 **subModel)
 
struct SvmModel233 ** SvmLoadModel (istream &f, RunLog &log)
 
void SvmPredictClass (SVMparam &svmParam, struct SvmModel233 **subModel, const struct svm_node *unknownClassFeatureData, kkint32 *votes, double *probabilities, kkint32 knownClass, kkint32 &predClass1, kkint32 &predClass2, kkint32 &predClass1Votes, kkint32 &predClass2Votes, double &predClass1Prob, double &predClass2Prob, double &probOfKnownClass, Ivector &winners, double **crossClassProbTable, double &breakTie)
 
void SvmPredictRaw (SvmModel233 **submodel, const svm_node *unKnownData, double &label, double &dist)
 
kkint32 SvmPredictTwoClass (const struct svm_parameter &param, SvmModel233 **submodel, const svm_node *unKnownData, kkint32 desired, double &dist, double &probability, kkint32 excludeSupportVectorIDX)
 
void SvmSaveModel (ostream &o, struct SvmModel233 **model)
 
struct SvmModel233 ** SvmTrainModel (const struct svm_parameter &param, struct svm_problem &subprob)
 

Variables

const char * FeatureDecriptions []
 
MLClassList globalClassList
 

Detailed Description

Namespace for all K^2 Machine Learning code.

This library provides data structures that support Machine Learning functionality.

A library of routines used for Machine Learning, building Classifiers, etc.

"Machine Learning Code"

"Feature Data"

There are several Feature Data formats supported. Each one has its own class that is derived from 'FeatureFileIO'. The description of the data is managed by 'FileDesc'. For each type of dataset there will exist on one instance of a FileDesc class.

See also
Attribute
FeatureNumList
FeatureFileIO
FeatureVector
FeatureVectorList
MLClass
BitReduction
FeatureEncoder
NormalizationParms
Orderings

"Learning Algorithms"

There are several learning algorithms implemented. The Learning algorithms are all sub-classed from 'Model' and their related parameters are all sub-classed from 'ModelParam'.

See also
Model
ModelKnn
ModelOldSVM
ModelSvmBase
ModelParam
TrainingClass
TrainingProcess2

"Analysis Routines"

See also
ConfusionMatrix2
CrossValidation
CrossValidationMxN
CrossValidationVoting
SizeDistribution
Author
Kurt Kramer * Date: 2009-04-16 *

There are several classes defined in this library but the central ones that should be understood are MLClass, FeatureVector, Model, FileDesc, and Attribute. there is support for reading and writing several feature Data file formats C45 probably being the most well known.

Typedef Documentation

Definition at line 214 of file Attribute.h.

Definition at line 212 of file Attribute.h.

Definition at line 156 of file Attribute.h.

Definition at line 72 of file Attribute.h.

Definition at line 120 of file BinaryClassParms.h.

Definition at line 90 of file ClassAssignments.h.

Definition at line 72 of file Classifier2.h.

Definition at line 284 of file Classifier2.h.

Definition at line 28 of file Classifier2.h.

Definition at line 38 of file ClassStatistic.h.

Definition at line 326 of file ConfusionMatrix2.h.

Definition at line 213 of file CrossValidation.h.

Definition at line 28 of file DuplicateImages.h.

Definition at line 119 of file DuplicateImages.h.

typedef std::vector<double> KKMLL::Dvector

Definition at line 20 of file SvmWrapper.h.

Definition at line 75 of file Model.h.

Definition at line 37 of file SVMModel.h.

Definition at line 45 of file FileDesc.h.

Definition at line 253 of file FeatureNumList.h.

Definition at line 51 of file FeatureNumList.h.

Definition at line 46 of file Model.h.

Definition at line 44 of file Model.h.

Definition at line 41 of file FeatureEncoder.h.

Definition at line 307 of file FileDesc.h.

Definition at line 41 of file FileDesc.h.

Definition at line 46 of file FeatureNumList.h.

typedef std::vector<float> KKMLL::Fvector

Definition at line 19 of file SvmWrapper.h.

typedef std::vector<kkint32> KKMLL::Ivector

Definition at line 18 of file SvmWrapper.h.

Definition at line 534 of file MLClass.h.

Definition at line 49 of file MLClass.h.

Definition at line 46 of file MLClass.h.

Definition at line 233 of file ModelDual.h.

Definition at line 120 of file ModelKnn.h.

Definition at line 266 of file ModelOldSVM.h.

Definition at line 24 of file ModelOldSVM.h.

Definition at line 201 of file ModelParam.h.

Definition at line 443 of file Model.h.

Definition at line 68 of file Model.h.

Definition at line 44 of file SVMModel.h.

Definition at line 77 of file SizeDistribution.h.

Definition at line 557 of file SVMModel.h.

Definition at line 286 of file SVMparam.h.

Definition at line 188 of file TrainingClass.h.

Definition at line 139 of file TrainingClass.h.

summary>Manages the creation and loading of training models.

remarks> A trained model can either be built from scratch using specified training data or a persistent instance can be loaded from a XMLStream. There are several static methods that are best used to manage the various situations such as "CreateTrainingProcess", "CreateTrainingProcessForLevel", "CreateTrainingProcessFromTrainingExamples", "LoadExistingTrainingProcess". The result of any of these methods is a TrainigProcess2 instance that you use to create a Classifier instance.

Supporting Classes:

  • TrainingConfiguration2 Manages defines the parameters of a classifier such as:
    1. Type of algorithm
    2. List Classes of and where training examples can be loaded from.
    3. Sub-Classifiers that is for any given class another "TrainingConfiguration2" can be specified indicating another classifier to be used when that class is predicted.
    4. Class Weights

Model Base class for all algorithms. SupportVectorMachine(SVM), USFCasCor, BFS-SVM, etc ....

Definition at line 68 of file Classifier2.h.

Definition at line 62 of file Classifier2.h.

Definition at line 227 of file Attribute.h.

Definition at line 337 of file FileDesc.h.

Definition at line 572 of file MLClass.h.

Definition at line 237 of file ModelDual.h.

Definition at line 124 of file ModelKnn.h.

Definition at line 480 of file Model.h.

Definition at line 561 of file SVMModel.h.

Definition at line 562 of file SVMModel.h.

Definition at line 302 of file SVMparam.h.

Definition at line 303 of file SVMparam.h.

typedef struct svm_node * KKMLL::XSpacePtr

Definition at line 58 of file SVMModel.h.

Enumeration Type Documentation

enum KKMLL::AttributeType : int
strong
Enumerator
NULLAttribute 
Ignore 
Numeric 
Nominal 
Ordinal 
Symbolic 

Same as Nominal, except the names file does not list all possible values. They have to be determined from the data file.

Definition at line 36 of file Attribute.h.

36  : int
37  {
39  Ignore,
40  Numeric,
41  Nominal,
42  Ordinal,
43  Symbolic /**< Same as Nominal, except the names file does not
44  * list all possible values. They have to be determined from
45  * the data file.
46  */
47  };
enum KKMLL::FeWhatToDo
strong
Enumerator
FeAsIs 
FeBinary 
FeScale 

Definition at line 39 of file FeatureEncoder.h.

enum KKMLL::LearnType
strong
Enumerator
NORMAL 
BAGGING 
BOOSTING 
SUBSPACE 
SAMPLESV 

Definition at line 9 of file SvmWrapper.h.

enum KKMLL::SVM_EncodingMethod : int
strong
Enumerator
Null 
NoEncoding 
Binary 
Scaled 

Definition at line 46 of file SVMparam.h.

enum KKMLL::SVM_KernalType : int
strong
Enumerator
Null 
Linear 
Polynomial 
RBF 

Definition at line 54 of file SVMparam.h.

enum KKMLL::SVM_MachineType : int
strong
Enumerator
Null 
OneVsOne 
OneVsAll 
BinaryCombos 
BoostSVM 

Definition at line 26 of file SVMparam.h.

enum KKMLL::SVM_SelectionMethod : int
strong
Enumerator
Null 
Voting 
Probability 

Definition at line 34 of file SVMparam.h.

Function Documentation

AttributeType KKMLL::AttributeTypeFromStr ( const KKStr s)

Definition at line 442 of file Attribute.cpp.

References KKB::KKStr::EqualIgnoreCase(), Ignore, Nominal, NULLAttribute, Numeric, Ordinal, and Symbolic.

Referenced by KKMLL::Attribute::ReadXML().

443 {
444  if (s.EqualIgnoreCase ("Ignore"))
445  return AttributeType::Ignore;
446 
447  else if (s.EqualIgnoreCase ("Numeric"))
448  return AttributeType::Numeric;
449 
450  else if (s.EqualIgnoreCase ("Nominal"))
451  return AttributeType::Nominal;
452 
453  else if (s.EqualIgnoreCase ("Ordinal"))
454  return AttributeType::Ordinal;
455 
456  else if (s.EqualIgnoreCase ("Symbolic"))
457  return AttributeType::Symbolic;
458 
459  else
460  return AttributeType::NULLAttribute;
461 }
bool EqualIgnoreCase(const KKStr &s2) const
Definition: KKStr.cpp:1250
const KKStr & KKMLL::AttributeTypeToStr ( AttributeType  type)

Definition at line 422 of file Attribute.cpp.

Referenced by KKMLL::FeatureVectorList::FeatureTypeStr(), and KKMLL::Attribute::TypeStr().

423 {
424  static vector<KKStr> AttributeTypeStrings =
425  {
426  "Null",
427  "Ignore",
428  "Numeric",
429  "Nominal",
430  "Ordinal"
431  };
432 
433  if ((type < (AttributeType)0) || ((kkuint32)type >= AttributeTypeStrings.size ()))
434  return KKStr::EmptyStr ();
435 
436  return AttributeTypeStrings[(int)type];
437 } /* TypeStr */
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
AttributeType
Definition: Attribute.h:36
void KKMLL::EncodeProblem ( const struct svm_paramater &  param,
struct svm_problem prob_in,
struct svm_problem prob_out 
)
SVM_EncodingMethod KKMLL::EncodingMethodFromStr ( const KKStr encodingMethodStr)

Definition at line 899 of file SVMparam.cpp.

References Binary, KKB::KKStr::Concat(), NoEncoding, Null, KKB::KKStr::operator==(), Scaled, and KKB::KKStr::ToUpper().

Referenced by KKMLL::SVMparam::ParseCmdLineParameter(), and KKMLL::FeatureEncoder::ReadXML().

900 {
901  KKStr encodingMethodUpper = encodingMethodStr.ToUpper ();
902 
903  if ((encodingMethodUpper == "BINARY") || (encodingMethodUpper == "BIN"))
904  return SVM_EncodingMethod::Binary;
905 
906  if (encodingMethodUpper == "SCALE")
907  return SVM_EncodingMethod::Scaled;
908 
909  if (encodingMethodUpper == "NONE")
910  return SVM_EncodingMethod::NoEncoding;
911 
912  return SVM_EncodingMethod::Null;
913 } /* EncodingMethodFromStr */
KKStr ToUpper() const
Definition: KKStr.cpp:2517
KKStr KKMLL::EncodingMethodToStr ( SVM_EncodingMethod  encodingMethod)
SVM_KernalType KKMLL::KernalTypeFromStr ( const KKStr kernalTypeStr)

Definition at line 932 of file SVMparam.cpp.

References KKB::KKStr::Concat(), Linear, KKB::KKStr::operator==(), Polynomial, RBF, and KKB::KKStr::Upper().

933 {
934  KKStr kernalTypeUpper = kernalTypeStr;
935  kernalTypeUpper.Upper ();
936 
937  if ((kernalTypeUpper == "LINEAR") ||
938  (kernalTypeUpper == "LIN") ||
939  (kernalTypeUpper == "L")
940  )
941  return SVM_KernalType::Linear;
942 
943  if ((kernalTypeUpper == "POLYNOMIAL") ||
944  (kernalTypeUpper == "POLY") ||
945  (kernalTypeUpper == "P") ||
946  (kernalTypeUpper == "PN")
947  )
948  return SVM_KernalType::Polynomial;
949 
950 
951  if ((kernalTypeUpper == "RBF") ||
952  (kernalTypeUpper == "R") ||
953  (kernalTypeUpper == "RADIALBASIS") ||
954  (kernalTypeUpper == "RADIALBASISFUNC") ||
955  (kernalTypeUpper == "RADIALBASISFUNCTION")
956  )
957  return SVM_KernalType::RBF;
958 
959  return SVM_KernalType::Linear;
960 } /* KernalTypeToStr */
void Upper()
Converts all characters in string to their Upper case equivalents via &#39;toupper&#39;.
Definition: KKStr.cpp:2461
KKStr KKMLL::KernalTypeToStr ( SVM_KernalType  kernalType)

Definition at line 917 of file SVMparam.cpp.

References Linear, Polynomial, and RBF.

918 {
919  switch (kernalType)
920  {
921  case SVM_KernalType::Linear: return "Linear";
922  case SVM_KernalType::Polynomial: return "Polynomial";
923  case SVM_KernalType::RBF: return "RBF";
924  default: return "UnKnown";
925  }
926 
927  return "";
928 } /* KernalTypeToStr */
SVM_MachineType KKMLL::MachineTypeFromStr ( const KKStr machineTypeStr)

Definition at line 986 of file SVMparam.cpp.

References BinaryCombos, BoostSVM, KKB::KKStr::Concat(), Null, OneVsAll, OneVsOne, KKB::KKStr::operator==(), and KKB::KKStr::ToUpper().

Referenced by KKMLL::SVMparam::ParseCmdLineParameter().

987 {
988  KKStr machineTypeUpper = machineTypeStr.ToUpper ();
989 
990  if (machineTypeUpper == "ONEVSONE")
991  return SVM_MachineType::OneVsOne;
992 
993  else if (machineTypeUpper == "ONEVSALL")
994  return SVM_MachineType::OneVsAll;
995 
996  else if (machineTypeUpper == "BINARY")
997  return SVM_MachineType::BinaryCombos;
998 
999  else if (machineTypeUpper == "BOOSTSVM")
1000  return SVM_MachineType::BoostSVM;
1001 
1002  return SVM_MachineType::Null;
1003 } /* MachineTypeFromStr */
KKStr ToUpper() const
Definition: KKStr.cpp:2517
KKStr KKMLL::MachineTypeToStr ( SVM_MachineType  machineType)

Definition at line 965 of file SVMparam.cpp.

References BinaryCombos, BoostSVM, OneVsAll, and OneVsOne.

Referenced by KKMLL::ModelOldSVM::Description(), KKMLL::SVMparam::ToString(), and KKMLL::SVMparam::WriteXML().

966 {
967  if (machineType == SVM_MachineType::OneVsOne)
968  return "OneVsOne";
969 
970  else if (machineType == SVM_MachineType::OneVsAll)
971  return "OneVsAll";
972 
973  else if (machineType == SVM_MachineType::BinaryCombos)
974  return "Binary";
975 
976  else if (machineType == SVM_MachineType::BoostSVM)
977  return "BoostSVM";
978 
979  return "";
980 } /* MachineTypeToStr */
AttributeType KKMLL::operator++ ( AttributeType  zed)

Definition at line 566 of file Attribute.cpp.

567 {
568  return (AttributeType)((int)zed + 1);
569 } /* operator++ */
AttributeType
Definition: Attribute.h:36
std::ostream & KKMLL::operator<< ( std::ostream &  os,
const FeatureNumList features 
)
std::ostream& KKMLL::operator<< ( std::ostream &  os,
const MLClassList classList 
)
KKStr & KKMLL::operator<< ( KKStr str,
const MLClassList classList 
)

Definition at line 1427 of file MLClass.cpp.

References KKMLL::MLClassList::ToString().

1430 {
1431  str << classList.ToString ();
1432  return str;
1433 }
KKStr ToString() const
Definition: MLClass.cpp:937
KKStr & KKMLL::operator<< ( KKStr left,
TrainingConfiguration2::ModelTypes  modelingMethod 
)

Definition at line 2002 of file TrainingConfiguration2.cpp.

References KKB::KKStr::Append(), and KKMLL::TrainingConfiguration2::ModelTypeToStr().

2005  {
2006  left.Append (TrainingConfiguration2::ModelTypeToStr (modelingMethod));
2007  return left;
2008  }
void Append(const char *buff)
Definition: KKStr.cpp:1783
ostream & KKMLL::operator<< ( std::ostream &  os,
TrainingConfiguration2::ModelTypes  modelingMethod 
)

Definition at line 2012 of file TrainingConfiguration2.cpp.

References KKMLL::TrainingConfiguration2::ModelTypeToStr(), and KKB::operator<<().

2015  {
2016  os << TrainingConfiguration2::ModelTypeToStr (modelingMethod);
2017  return os;
2018  }
ostream & KKMLL::operator<< ( ostream &  os,
const FeatureNumList features 
)

Definition at line 761 of file FeatureNumList.cpp.

References KKB::operator<<(), and KKMLL::FeatureNumList::ToString().

764  {
765  os << features.ToString ();
766  return os;
767  }
KKStr ToString() const
Returns comma delimited list of all features selected; will make use of range specification.
bool KKMLL::PairCompareOperator ( ProbNamePair  l,
ProbNamePair  r 
)

Definition at line 1568 of file SVMModel.cpp.

References KKMLL::ProbNamePair::probability.

1569  {
1570  return l.probability > r.probability;
1571  }
double probability
Definition: SVMModel.h:72
SVM_SelectionMethod KKMLL::SelectionMethodFromStr ( const KKStr selectionMethodStr)

Definition at line 1022 of file SVMparam.cpp.

References KKB::KKStr::Concat(), Null, KKB::KKStr::operator==(), Probability, KKB::KKStr::ToUpper(), and Voting.

Referenced by KKMLL::SVMparam::ParseCmdLineParameter().

1023 {
1024  KKStr selectionMethodUpper = selectionMethodStr.ToUpper ();
1025 
1026  if ((selectionMethodUpper == "VOTE") || (selectionMethodUpper == "VOTING"))
1027  return SVM_SelectionMethod::Voting;
1028 
1029  if ((selectionMethodUpper == "P") ||
1030  (selectionMethodUpper == "PROB") ||
1031  (selectionMethodUpper == "PROBABILITY")
1032  )
1033  return SVM_SelectionMethod::Probability;
1034 
1035  return SVM_SelectionMethod::Null;
1036 
1037 } /* SelectionMethodFromStr */
KKStr ToUpper() const
Definition: KKStr.cpp:2517
KKStr KKMLL::SelectionMethodToStr ( SVM_SelectionMethod  selectionMethod)

Definition at line 1008 of file SVMparam.cpp.

References Probability, and Voting.

Referenced by KKMLL::ModelOldSVM::Description(), KKMLL::SVMparam::ToString(), and KKMLL::SVMparam::WriteXML().

1009 {
1010  if (selectionMethod == SVM_SelectionMethod::Voting)
1011  return "Voting";
1012 
1013  if (selectionMethod == SVM_SelectionMethod::Probability)
1014  return "Probability";
1015 
1016  return "";
1017 } /* SelectionMethodToStr */
void KKMLL::SvmDestroyModel ( struct SvmModel233 **  subModel)

Definition at line 742 of file SvmWrapper.cpp.

References SVM233::svm_destroy_model().

743 {
744  svm_destroy_model (subModel[0]);
745 }
void svm_destroy_model(struct SvmModel233 *model)
Definition: svm.cpp:4442
struct SvmModel233 ** KKMLL::SvmLoadModel ( istream &  f,
RunLog log 
)

Definition at line 722 of file SvmWrapper.cpp.

References SVM233::Svm_Load_Model().

725 {
726  SvmModel233** models = new SvmModel233*[1];
727  models[0] = Svm_Load_Model (f, log);
728 
729  if (models[0] == NULL)
730  {
731  delete[] models;
732  models = NULL;
733  }
734 
735  return models;
736 }
struct SvmModel233 * Svm_Load_Model(std::istream &f, RunLog &log)
void KKMLL::SvmPredictClass ( SVMparam svmParam,
struct SvmModel233 **  subModel,
const struct svm_node unknownClassFeatureData,
kkint32 votes,
double *  probabilities,
kkint32  knownClass,
kkint32 predClass1,
kkint32 predClass2,
kkint32 predClass1Votes,
kkint32 predClass2Votes,
double &  predClass1Prob,
double &  predClass2Prob,
double &  probOfKnownClass,
Ivector winners,
double **  crossClassProbTable,
double &  breakTie 
)
Parameters
[in]svmParamStructure that has all the parameters used for building the SVM.
[in]subModelThis is the model(classifier) returned by SvmTrainModel.
[in]probabilitiesArray that must be as big as number of classes the probability of each class will be returned where there sum is 1.0
[in]unknownClassFeatureDatadata structure you build that represents a sparse array of the feature data that is to be used for prediction.
[out]probabilitiesarray that will receive the predicted probability for each class.
[in]knownClassIf you happen to know hat the class really is you can specify it here so as to get the probability of it returned back to you.
[out]predClass1The prediction will be returned back in this field.
[out]predClass2The second most likely class based off either probability or number of votes.
[out]predClass1VotesNumber votes that class 'predClass1' received.
[out]predClass2VotesNumber votes that class 'predClass2' received.
[out]predClass1ProbProbability that class 'predClass1' received.
[out]predClass2ProbProbability that class 'predClass2' received.
[out]probOfKnownClassProbability that 'knownClass' class receved.
[out]winnersIf voting was specified in 'svmParam' and there was a tie between 2 or more classes; them the classes that ties will be in this vector.
[in]crossClassProbTableA 2 dimensional table that will have the computed probabilities between all the possible 2 class combinations.
[in]breakTieThe difference in probability between the two most likely classes.

Definition at line 585 of file SvmWrapper.cpp.

References GreaterVotes(), SVM233::SvmModel233::nr_class, KKMLL::SVMparam::Param(), Probability, and KKMLL::SVMparam::SelectionMethod().

602 {
603  const struct svm_parameter& param = svmParam.Param ();
604 
605  kkint32 NUMCLASS = subModel[0][0].nr_class;
606 
607  kkint32 numBinary = (NUMCLASS * (NUMCLASS - 1)) / 2;
608  Dvector dist (numBinary, 0);
609 
610 
611  svm_predict (subModel[0], unknownClassFeatureData, dist, winners, -1);
612 
613 
614  ComputeProb (NUMCLASS,
615  svmParam.ProbClassPairs (),
616  dist, // Distances for each binary classifier from decision boundary.
617  crossClassProbTable, // Will get Probabilities between classes.
618  votes,
619  probabilities, // Probabilities for Each Class
620  knownClass // -1 = Don't know the class otherwise the Number of the Class.
621  );
622 
623  GreaterVotes ((svmParam.SelectionMethod () == SVM_SelectionMethod::Probability),
624  NUMCLASS,
625  votes,
626  probabilities,
627  predClass1,
628  predClass2
629  );
630  if (predClass1 >= 0)
631  {
632  predClass1Votes = votes[predClass1];
633  predClass1Prob = probabilities[predClass1];
634  }
635 
636  if (predClass2 >= 0)
637  {
638  predClass2Votes = votes[predClass2];
639  predClass2Prob = probabilities[predClass2];
640  }
641 
642  if (knownClass >= 0)
643  probOfKnownClass = probabilities[knownClass];
644 
645  breakTie = (predClass1Prob - predClass2Prob);
646 } /* SvmPredictClass */
std::vector< double > Dvector
Definition: SvmWrapper.h:20
__int32 kkint32
Definition: KKBaseTypes.h:88
void ComputeProb(kkint32 numClasses, const VectorFloat &probClassPairs, vector< double > &dist, double **crossClassProbTable, kkint32 *votes, double *probabilities, kkint32 knownClassNum)
Definition: SvmWrapper.cpp:472
const VectorFloat & ProbClassPairs() const
Definition: SVMparam.h:161
kkint32 nr_class
Definition: svm.h:138
void GreaterVotes(bool useProbability, kkint32 numClasses, kkint32 *votes, double *probabilities, kkint32 &pred1Idx, kkint32 &pred2Idx)
Definition: SvmWrapper.cpp:175
double svm_predict(const struct SvmModel233 *model, const struct svm_node *x)
SVM_SelectionMethod SelectionMethod() const
Definition: SVMparam.h:169
const svm_parameter & Param() const
Definition: SVMparam.h:159
void KKMLL::SvmPredictRaw ( SvmModel233 **  submodel,
const svm_node unKnownData,
double &  label,
double &  dist 
)

Definition at line 684 of file SvmWrapper.cpp.

References SVM233::SvmModel233::nr_class, KKB::osWaitForEnter(), and SVM233::svm_predictTwoClasses().

Referenced by KKMLL::SVMModel::PredictRaw().

689 {
690  if (submodel[0]->nr_class != 2)
691  {
692  cerr << endl
693  << endl
694  << "SvmPredictTwoClass *** ERROR ***" << endl
695  << endl
696  << "Number of classes should be equal to two." << endl
697  << endl;
698  osWaitForEnter ();
699  exit (-1);
700  }
701 
702  dist = 0.0;
703 
704  label = svm_predictTwoClasses (submodel[0], unKnownData, dist, -1);
705 
706  return;
707 } /* SvmPredictRaw */
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
void osWaitForEnter()
double svm_predictTwoClasses(const SvmModel233 *model, const svm_node *x, double &dist, kkint32 excludeSupportVectorIDX)
Definition: svm.cpp:4218
kkint32 KKMLL::SvmPredictTwoClass ( const struct svm_parameter param,
SvmModel233 **  submodel,
const svm_node unKnownData,
kkint32  desired,
double &  dist,
double &  probability,
kkint32  excludeSupportVectorIDX 
)
void KKMLL::SvmSaveModel ( ostream &  o,
struct SvmModel233 **  model 
)

Definition at line 711 of file SvmWrapper.cpp.

References SVM233::Svm_Save_Model().

714 {
715  Svm_Save_Model (o, model[0]);
716 }
void Svm_Save_Model(std::ostream &o, const SvmModel233 *model)
struct SvmModel233 ** KKMLL::SvmTrainModel ( const struct svm_parameter param,
struct svm_problem subprob 
)

Definition at line 543 of file SvmWrapper.cpp.

References BAGGING, BOOSTING, SVM233::svm_parameter::boosting, SVM233::svm_parameter::dimSelect, NORMAL, SVM233::svm_parameter::numSVM, SVM233::svm_parameter::sample, SAMPLESV, SVM233::svm_parameter::sampleSV, SUBSPACE, and SVM233::svm_train().

546 {
547  struct SvmModel233 **submodel;
548 
549  kkint32 numSVM = param.numSVM;
550  kkint32 sample = (kkint32) (param.sample);
551 
552  //kkint32 numClass=param.numClass;
553  kkint32 sampleSV = param.sampleSV;
554  kkint32 boosting = param.boosting;
555  kkint32 dimSelect = param.dimSelect;
556 
557  LearnType learnType;
558 
559  if ((numSVM == 1) && (sample == 100))
560  learnType= LearnType::NORMAL;
561 
562  else if (dimSelect > 0)
563  learnType = LearnType::SUBSPACE;
564 
565  else if (boosting != 0)
566  learnType=LearnType::BOOSTING;
567 
568  else if(sampleSV!=0)
569  learnType=LearnType::SAMPLESV;
570 
571  else
572  learnType=LearnType::BAGGING;
573 
574  submodel = new SvmModel233* [numSVM];
575  submodel[0] = svm_train (&subprob, &param);
576 
577  return submodel;
578 } /* SvmTrainModel */
kkint32 dimSelect
Definition: svm.h:102
__int32 kkint32
Definition: KKBaseTypes.h:88
kkint32 boosting
Definition: svm.h:98
LearnType
Definition: SvmWrapper.h:9
kkint32 sampleSV
Definition: svm.h:108
struct SvmModel233 * svm_train(const struct svm_problem *prob, const struct svm_parameter *param)
kkint32 numSVM
Definition: svm.h:106

Variable Documentation

const char * KKMLL::FeatureDecriptions

Definition at line 314 of file FeatureNumList_Old.h.

MLClassList KKMLL::globalClassList