SHOGUN  v1.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
List of all members | 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]

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)
- Public Member Functions inherited from CSGObject
 CSGObject ()
 CSGObject (const CSGObject &orig)
virtual ~CSGObject ()
virtual const char * get_name () const =0
virtual bool is_generic (EPrimitiveType *generic) const
template<class T >
void set_generic ()
void unset_generic ()
virtual void print_serializable (const char *prefix="")
virtual bool save_serializable (CSerializableFile *file, const char *prefix="")
virtual bool load_serializable (CSerializableFile *file, const char *prefix="")
void set_global_io (SGIO *io)
SGIOget_global_io ()
void set_global_parallel (Parallel *parallel)
Parallelget_global_parallel ()
void set_global_version (Version *version)
Versionget_global_version ()
SGVector< char * > get_modelsel_names ()
char * get_modsel_param_descr (const char *param_name)
index_t get_modsel_param_index (const char *param_name)

Protected Member Functions

virtual bool train_machine (CFeatures *data=NULL)
virtual void store_model_features ()
- Protected Member Functions inherited from CSGObject
virtual void load_serializable_pre () throw (ShogunException)
virtual void load_serializable_post () throw (ShogunException)
virtual void save_serializable_pre () throw (ShogunException)
virtual void save_serializable_post () throw (ShogunException)

Protected Attributes

float64_t max_train_time
CLabelslabels
ESolverType solver_type
bool m_store_model_features

Additional Inherited Members

- Public Attributes inherited from CSGObject
SGIOio
Parallelparallel
Versionversion
Parameterm_parameters
Parameterm_model_selection_parameters

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 CKernelMachine, COnlineLinearMachine, CWDSVMOcas, CLinearMachine, CHierarchical, CMultiClassSVM, CDistanceMachine, CGaussianNaiveBayes, CKNN, CKRR, and CPluginEstimate.

virtual CLabels* apply ( CFeatures data)
pure virtual

apply machine to data

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

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

float64_t apply ( int32_t  num)
virtual

apply machine to one example

abstract base method

Parameters
numwhich example to apply machine to
Returns
infinite float value

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
float64_t get_label ( int32_t  i)
virtual

get one specific label

Parameters
iindex 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
srcfilefile to load from
Returns
failure

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

Parameters
dstfilefile to save to
Returns
failure

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

set labels

Parameters
lablabels

Definition at line 63 of file Machine.cpp.

void set_max_train_time ( float64_t  t)

set maximum training time

Parameters
tmaximimum training time

Definition at line 84 of file Machine.cpp.

void set_solver_type ( ESolverType  st)

set solver type

Parameters
stsolver 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_modelwhether model should be stored after training

Definition at line 109 of file Machine.cpp.

virtual void store_model_features ( )
protectedvirtual

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.

Definition at line 240 of file Machine.h.

bool train ( CFeatures data = NULL)
virtual

train machine

Parameters
datatraining 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 CGaussianNaiveBayes, CSGDQN, COnlineSVMSGD, CAveragedPerceptron, and COnlineLibLinear.

Definition at line 35 of file Machine.cpp.

virtual bool train_machine ( CFeatures data = NULL)
protectedvirtual

train machine

Parameters
datatraining 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 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.

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.

float64_t max_train_time
protected

maximum training time

Definition at line 248 of file Machine.h.

ESolverType solver_type
protected

solver type

Definition at line 254 of file Machine.h.


The documentation for this class was generated from the following files:

SHOGUN Machine Learning Toolbox - Documentation