Public Member Functions | Protected Member Functions | Protected Attributes

CMachine Class Reference


Detailed Description

A generic learning machine interface.

A machine takes as input CFeatures and (optionally) CLabels. Later subclasses may specialize the machine to e.g. require labels and a kernel or labels and (real-valued) features.

A machine needs to override the train() function for training, the functions apply(idx) (optionally apply() to predict on the whole set of examples) and the load and save routines.

Definition at line 96 of file Machine.h.

Inheritance diagram for CMachine:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 CMachine ()
virtual ~CMachine ()
virtual bool train (CFeatures *data=NULL)
virtual CLabelsapply ()=0
virtual CLabelsapply (CFeatures *data)=0
virtual float64_t apply (int32_t num)
virtual bool load (FILE *srcfile)
virtual bool save (FILE *dstfile)
virtual void set_labels (CLabels *lab)
virtual CLabelsget_labels ()
virtual float64_t get_label (int32_t i)
void set_max_train_time (float64_t t)
float64_t get_max_train_time ()
virtual EClassifierType get_classifier_type ()
void set_solver_type (ESolverType st)
ESolverType get_solver_type ()
virtual void set_store_model_features (bool store_model)

Protected Member Functions

virtual bool train_machine (CFeatures *data=NULL)
virtual void store_model_features ()

Protected Attributes

float64_t max_train_time
CLabelslabels
ESolverType solver_type
bool m_store_model_features

Constructor & Destructor Documentation

CMachine (  ) 

constructor

Definition at line 17 of file Machine.cpp.

~CMachine (  )  [virtual]

destructor

Definition at line 30 of file Machine.cpp.


Member Function Documentation

virtual CLabels* apply (  )  [pure virtual]

apply machine to the currently set features

Returns:
output 'labels'

Implemented in CGaussianNaiveBayes, CKNN, CPluginEstimate, CMultiClassSVM, CWDSVMOcas, CHierarchical, CDistanceMachine, CKernelMachine, CLinearMachine, COnlineLinearMachine, and CKRR.

float64_t apply ( int32_t  num  )  [virtual]

apply machine to one example

abstract base method

Parameters:
num which example to apply machine to
Returns:
infinite float value

Reimplemented in CGaussianNaiveBayes, CKNN, CPluginEstimate, CMultiClassSVM, CScatterSVM, CWDSVMOcas, CHierarchical, CDistanceMachine, CKernelMachine, CLinearMachine, COnlineLinearMachine, and CKRR.

Definition at line 45 of file Machine.cpp.

virtual CLabels* apply ( CFeatures data  )  [pure virtual]

apply machine to data

Parameters:
data (test)data to be classified
Returns:
classified labels

Implemented in CGaussianNaiveBayes, CKNN, CPluginEstimate, CDomainAdaptationSVM, CMultiClassSVM, CWDSVMOcas, CHierarchical, CDistanceMachine, CKernelMachine, CLinearMachine, and COnlineLinearMachine.

EClassifierType get_classifier_type (  )  [virtual]
float64_t get_label ( int32_t  i  )  [virtual]

get one specific label

Parameters:
i index of label to get
Returns:
value of label at index i

Definition at line 76 of file Machine.cpp.

CLabels * get_labels (  )  [virtual]

get labels

Returns:
labels

Definition at line 70 of file Machine.cpp.

float64_t get_max_train_time (  ) 

get maximum training time

Returns:
maximum training time

Definition at line 89 of file Machine.cpp.

ESolverType get_solver_type (  ) 

get solver type

Returns:
solver

Definition at line 104 of file Machine.cpp.

bool load ( FILE *  srcfile  )  [virtual]

load Machine from file

abstract base method

Parameters:
srcfile file to load from
Returns:
failure

Reimplemented in CKNN, CMultiClassSVM, CSVM, CHierarchical, CKMeans, CLinearMachine, COnlineLinearMachine, and CKRR.

Definition at line 51 of file Machine.cpp.

bool save ( FILE *  dstfile  )  [virtual]

save Machine to file

abstract base method

Parameters:
dstfile file to save to
Returns:
failure

Reimplemented in CKNN, CMultiClassSVM, CSVM, CHierarchical, CKMeans, CLinearMachine, COnlineLinearMachine, and CKRR.

Definition at line 57 of file Machine.cpp.

void set_labels ( CLabels lab  )  [virtual]

set labels

Parameters:
lab labels

Definition at line 63 of file Machine.cpp.

void set_max_train_time ( float64_t  t  ) 

set maximum training time

Parameters:
t maximimum training time

Definition at line 84 of file Machine.cpp.

void set_solver_type ( ESolverType  st  ) 

set solver type

Parameters:
st solver type

Definition at line 99 of file Machine.cpp.

void set_store_model_features ( bool  store_model  )  [virtual]

Setter for store-model-features-after-training flag

Parameters:
store_model whether model should be stored after training

Definition at line 109 of file Machine.cpp.

virtual void store_model_features (  )  [protected, virtual]

Stores feature data of underlying model. After this method has been called, it is possible to change the machine's feature data and call apply(), which is then performed on the training feature data that is part of the machine's model.

Base method, has to be implemented in order to allow cross-validation and model selection.

NOT IMPLEMENTED! Has to be done in subclasses

Reimplemented in CKNN, CHierarchical, CKMeans, CDistanceMachine, CKernelMachine, and CLinearMachine.

Definition at line 240 of file Machine.h.

bool train ( CFeatures data = NULL  )  [virtual]

train machine

Parameters:
data training data (parameter can be avoided if distance or kernel-based classifiers are used and distance/kernels are initialized with train data). If flag is set, model features will be stored after training.
Returns:
whether training was successful

Reimplemented in CAveragedPerceptron, CGaussianNaiveBayes, COnlineLibLinear, COnlineSVMSGD, and CSGDQN.

Definition at line 35 of file Machine.cpp.

virtual bool train_machine ( CFeatures data = NULL  )  [protected, virtual]

train machine

Parameters:
data training data (parameter can be avoided if distance or kernel-based classifiers are used and distance/kernels are initialized with train data)

NOT IMPLEMENTED!

Returns:
whether training was successful

Reimplemented in CKNN, CLDA, CMKL, CMKLMultiClass, CPerceptron, CPluginEstimate, CCPLEXSVM, CDomainAdaptationSVM, CGMNPSVM, CGNPPSVM, CGPBTSVM, CLaRank, CLibLinear, CLibSVM, CLibSVMMultiClass, CLibSVMOneClass, CMPDSVM, CScatterSVM, CSubGradientSVM, CSVMLight, CSVMLightOneClass, CSVMLin, CSVMOcas, CSVMSGD, CWDSVMOcas, CVowpalWabbit, CHierarchical, CKMeans, CKRR, CLibSVR, and CSVRLight.

Definition at line 223 of file Machine.h.


Member Data Documentation

CLabels* labels [protected]

labels

Definition at line 251 of file Machine.h.

bool m_store_model_features [protected]

whether model features should be stored after training

Definition at line 257 of file Machine.h.

maximum training time

Definition at line 248 of file Machine.h.

ESolverType solver_type [protected]

solver type

Reimplemented in CLibSVM, and CLibSVMMultiClass.

Definition at line 254 of file Machine.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation