SHOGUN
v1.1.0
|
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.
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 17 of file Machine.cpp.
~CMachine | ( | ) | [virtual] |
destructor
Definition at line 30 of file Machine.cpp.
apply machine to the currently set features
Implemented in CKernelMachine, COnlineLinearMachine, CWDSVMOcas, CLinearMachine, CHierarchical, CMultiClassSVM, CDistanceMachine, CGaussianNaiveBayes, CKNN, CKRR, and CPluginEstimate.
apply machine to data
data | (test)data to be classified |
Implemented in CKernelMachine, COnlineLinearMachine, CWDSVMOcas, CLinearMachine, CHierarchical, CMultiClassSVM, CDistanceMachine, CGaussianNaiveBayes, CKNN, and CPluginEstimate.
apply machine to one example
abstract base method
num | which example to apply machine to |
Reimplemented in CKernelMachine, COnlineLinearMachine, CWDSVMOcas, CLinearMachine, CHierarchical, CMultiClassSVM, CDistanceMachine, CGaussianNaiveBayes, CKNN, CKRR, CScatterSVM, and CPluginEstimate.
Definition at line 45 of file Machine.cpp.
EClassifierType get_classifier_type | ( | ) | [virtual] |
get classifier type
Reimplemented in CLaRank, CKRR, CGaussianNaiveBayes, CLDA, CLibLinear, CScatterSVM, CKNN, CLibSVR, CSGDQN, CSVMSGD, CDomainAdaptationSVMLinear, CSVMOcas, COnlineSVMSGD, CMKLMultiClass, CKMeans, CWDSVMOcas, CHierarchical, CMKLClassification, CMKLOneClass, CMKLRegression, CAveragedPerceptron, CPerceptron, CLibSVM, CGMNPSVM, CSubGradientSVM, CSVMLin, CGPBTSVM, CLibSVMMultiClass, CLibSVMOneClass, CGNPPSVM, CMPDSVM, and CCPLEXSVM.
Definition at line 94 of file Machine.cpp.
get one specific label
i | index of label to get |
Definition at line 76 of file Machine.cpp.
CLabels * get_labels | ( | ) | [virtual] |
bool load | ( | FILE * | srcfile | ) | [virtual] |
load Machine from file
abstract base method
srcfile | file to load from |
Reimplemented in CMultiClassSVM, COnlineLinearMachine, CLinearMachine, CKNN, CKRR, CSVM, CKMeans, and CHierarchical.
Definition at line 51 of file Machine.cpp.
bool save | ( | FILE * | dstfile | ) | [virtual] |
save Machine to file
abstract base method
dstfile | file to save to |
Reimplemented in CMultiClassSVM, COnlineLinearMachine, CLinearMachine, CKNN, CKRR, CSVM, CKMeans, and CHierarchical.
Definition at line 57 of file Machine.cpp.
void set_labels | ( | CLabels * | lab | ) | [virtual] |
void set_max_train_time | ( | float64_t | t | ) |
set maximum training time
t | maximimum training time |
Definition at line 84 of file Machine.cpp.
void set_solver_type | ( | ESolverType | st | ) |
void set_store_model_features | ( | bool | store_model | ) | [virtual] |
Setter for store-model-features-after-training flag
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 CKernelMachine, CLinearMachine, CKNN, CKMeans, CDistanceMachine, and CHierarchical.
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 CGaussianNaiveBayes, CSGDQN, COnlineSVMSGD, CAveragedPerceptron, and COnlineLibLinear.
Definition at line 35 of file Machine.cpp.
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 CLaRank, CWDSVMOcas, CMKL, CPluginEstimate, CLibLinear, CSVMOcas, CKNN, CMKLMultiClass, CSubGradientSVM, CSVMSGD, CVowpalWabbit, CKMeans, CKRR, CLDA, CHierarchical, CScatterSVM, CSVMLin, CLibSVR, CPerceptron, CGMNPSVM, CLibSVM, CGPBTSVM, CLibSVMMultiClass, CLibSVMOneClass, CGNPPSVM, CMPDSVM, and CCPLEXSVM.
bool m_store_model_features [protected] |
float64_t max_train_time [protected] |
ESolverType solver_type [protected] |
solver type
Reimplemented in CLibSVM, and CLibSVMMultiClass.