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 97 of file Machine.h.
Public Member Functions | |
CMachine () | |
virtual | ~CMachine () |
virtual bool | train (CFeatures *data=NULL) |
virtual CLabels * | apply ()=0 |
virtual CLabels * | apply (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 CLabels * | get_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 |
CLabels * | labels |
ESolverType | solver_type |
bool | m_store_model_features |
CMachine | ( | ) |
constructor
Definition at line 16 of file Machine.cpp.
~CMachine | ( | ) | [virtual] |
Definition at line 29 of file Machine.cpp.
virtual CLabels* apply | ( | ) | [pure virtual] |
apply machine to the currently set features
Implemented in CGaussianNaiveBayes, CKNN, CPluginEstimate, CMultiClassSVM, CWDSVMOcas, CHierarchical, CDistanceMachine, CKernelMachine, CLinearMachine, COnlineLinearMachine, and CKRR.
virtual float64_t apply | ( | int32_t | num | ) | [virtual] |
apply machine to one example
abstract base method
num | which example to apply machine to |
Reimplemented in CGaussianNaiveBayes, CKNN, CPluginEstimate, CMultiClassSVM, CScatterSVM, CWDSVMOcas, CHierarchical, CDistanceMachine, CKernelMachine, CLinearMachine, COnlineLinearMachine, and CKRR.
apply machine to data
data | (test)data to be classified |
Implemented in CGaussianNaiveBayes, CKNN, CPluginEstimate, CDomainAdaptationSVM, CMultiClassSVM, CWDSVMOcas, CHierarchical, CDistanceMachine, CKernelMachine, CLinearMachine, and COnlineLinearMachine.
virtual EClassifierType get_classifier_type | ( | ) | [virtual] |
get classifier type
Reimplemented in CAveragedPerceptron, CGaussianNaiveBayes, CKNN, CLDA, CMKLClassification, CMKLMultiClass, CMKLOneClass, CPerceptron, CCPLEXSVM, CDomainAdaptationSVM, CDomainAdaptationSVMLinear, CGMNPSVM, CGNPPSVM, CGPBTSVM, CLaRank, CLibLinear, CLibSVM, CLibSVMMultiClass, CLibSVMOneClass, CMPDSVM, COnlineSVMSGD, CScatterSVM, CSGDQN, CSubGradientSVM, CSVMLight, CSVMLightOneClass, CSVMLin, CSVMOcas, CSVMSGD, CWDSVMOcas, CHierarchical, CKMeans, CKRR, CLibSVR, CMKLRegression, and CSVRLight.
virtual float64_t get_label | ( | int32_t | i | ) | [virtual] |
virtual CLabels* get_labels | ( | ) | [virtual] |
float64_t get_max_train_time | ( | ) |
ESolverType get_solver_type | ( | ) |
virtual bool load | ( | FILE * | srcfile | ) | [virtual] |
load Machine from file
abstract base method
srcfile | file to load from |
Reimplemented in CKNN, CMultiClassSVM, CSVM, CHierarchical, CKMeans, CLinearMachine, COnlineLinearMachine, and CKRR.
virtual bool save | ( | FILE * | dstfile | ) | [virtual] |
save Machine to file
abstract base method
dstfile | file to save to |
Reimplemented in CKNN, CMultiClassSVM, CSVM, CHierarchical, CKMeans, CLinearMachine, COnlineLinearMachine, and CKRR.
virtual void set_labels | ( | CLabels * | lab | ) | [virtual] |
void set_max_train_time | ( | float64_t | t | ) |
void set_solver_type | ( | ESolverType | st | ) |
virtual void set_store_model_features | ( | bool | store_model | ) | [virtual] |
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.
virtual bool train | ( | CFeatures * | data = NULL |
) | [virtual] |
train machine
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. |
Reimplemented in CAveragedPerceptron, CGaussianNaiveBayes, COnlineLibLinear, COnlineSVMSGD, and CSGDQN.
virtual bool train_machine | ( | CFeatures * | data = NULL |
) | [protected, virtual] |
train machine
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!
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.
bool m_store_model_features [protected] |
float64_t max_train_time [protected] |
ESolverType solver_type [protected] |
solver type
Reimplemented in CLibSVM, and CLibSVMMultiClass.