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
CMKLMultiClass Class Reference

Detailed Description

MKLMultiClass is a class for L1-norm multiclass MKL.

It is based on the GMNPSVM Multiclass SVM. Its own parameters are the L2 norm weight change based MKL Its termination criterion set by void set_mkl_epsilon(float64_t eps ); and the maximal number of MKL iterations set by void set_max_num_mkliters(int32_t maxnum); It passes the regularization constants C1 and C2 to GMNPSVM.

Definition at line 32 of file MKLMultiClass.h.

Inheritance diagram for CMKLMultiClass:
Inheritance graph
[legend]

Public Member Functions

 CMKLMultiClass ()
 CMKLMultiClass (float64_t C, CKernel *k, CLabels *lab)
virtual ~CMKLMultiClass ()
virtual EClassifierType get_classifier_type ()
float64_tgetsubkernelweights (int32_t &numweights)
void set_mkl_epsilon (float64_t eps)
void set_max_num_mkliters (int32_t maxnum)
virtual void set_mkl_norm (float64_t norm)
- Public Member Functions inherited from CMultiClassSVM
 CMultiClassSVM ()
 CMultiClassSVM (EMultiClassSVM type)
 CMultiClassSVM (EMultiClassSVM type, float64_t C, CKernel *k, CLabels *lab)
virtual ~CMultiClassSVM ()
bool create_multiclass_svm (int32_t num_classes)
bool set_svm (int32_t num, CSVM *svm)
CSVMget_svm (int32_t num)
int32_t get_num_svms ()
void cleanup ()
virtual CLabelsapply ()
virtual CLabelsapply (CFeatures *data)
virtual float64_t apply (int32_t num)
virtual CLabelsclassify_one_vs_rest ()
virtual float64_t classify_example_one_vs_rest (int32_t num)
CLabelsclassify_one_vs_one ()
float64_t classify_example_one_vs_one (int32_t num)
bool load (FILE *svm_file)
bool save (FILE *svm_file)
EMultiClassSVM get_multiclass_type ()
- Public Member Functions inherited from CSVM
 CSVM (int32_t num_sv=0)
 CSVM (float64_t C, CKernel *k, CLabels *lab)
virtual ~CSVM ()
void set_defaults (int32_t num_sv=0)
virtual SGVector< float64_tget_linear_term ()
virtual void set_linear_term (SGVector< float64_t > linear_term)
void set_nu (float64_t nue)
void set_C (float64_t c_neg, float64_t c_pos)
void set_epsilon (float64_t eps)
void set_tube_epsilon (float64_t eps)
float64_t get_tube_epsilon ()
void set_qpsize (int32_t qps)
float64_t get_epsilon ()
float64_t get_nu ()
float64_t get_C1 ()
float64_t get_C2 ()
int32_t get_qpsize ()
void set_shrinking_enabled (bool enable)
bool get_shrinking_enabled ()
float64_t compute_svm_dual_objective ()
float64_t compute_svm_primal_objective ()
void set_objective (float64_t v)
float64_t get_objective ()
void set_callback_function (CMKL *m, bool(*cb)(CMKL *mkl, const float64_t *sumw, const float64_t suma))
virtual const char * get_name () const
- Public Member Functions inherited from CKernelMachine
 CKernelMachine ()
virtual ~CKernelMachine ()
void set_kernel (CKernel *k)
CKernelget_kernel ()
void set_batch_computation_enabled (bool enable)
bool get_batch_computation_enabled ()
void set_linadd_enabled (bool enable)
bool get_linadd_enabled ()
void set_bias_enabled (bool enable_bias)
bool get_bias_enabled ()
float64_t get_bias ()
void set_bias (float64_t bias)
int32_t get_support_vector (int32_t idx)
float64_t get_alpha (int32_t idx)
bool set_support_vector (int32_t idx, int32_t val)
bool set_alpha (int32_t idx, float64_t val)
int32_t get_num_support_vectors ()
void set_alphas (SGVector< float64_t > alphas)
void set_support_vectors (SGVector< int32_t > svs)
SGVector< int32_t > get_support_vectors ()
SGVector< float64_tget_alphas ()
bool create_new_model (int32_t num)
bool init_kernel_optimization ()
- Public Member Functions inherited from CMachine
 CMachine ()
virtual ~CMachine ()
virtual bool train (CFeatures *data=NULL)
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 ()
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 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

 CMKLMultiClass (const CMKLMultiClass &cm)
CMKLMultiClass operator= (const CMKLMultiClass &cm)
void initlpsolver ()
void initsvm ()
virtual bool evaluatefinishcriterion (const int32_t numberofsilpiterations)
void addingweightsstep (const std::vector< float64_t > &curweights)
float64_t getsumofsignfreealphas ()
float64_t getsquarenormofprimalcoefficients (const int32_t ind)
virtual bool train_machine (CFeatures *data=NULL)

Protected Attributes

CGMNPSVMsvm
MKLMultiClassOptimizationBaselpw
::std::vector< std::vector
< float64_t > > 
weightshistory
float64_t mkl_eps
int32_t max_num_mkl_iters
float64_t pnorm
std::vector< float64_tnormweightssquared
- Protected Attributes inherited from CMultiClassSVM
EMultiClassSVM multiclass_type
int32_t m_num_classes
int32_t m_num_svms
CSVM ** m_svms
- Protected Attributes inherited from CSVM
SGVector< float64_tm_linear_term
bool svm_loaded
float64_t epsilon
float64_t tube_epsilon
float64_t nu
float64_t C1
float64_t C2
float64_t objective
int32_t qpsize
bool use_shrinking
bool(* callback )(CMKL *mkl, const float64_t *sumw, const float64_t suma)
CMKLmkl
- Protected Attributes inherited from CKernelMachine
CKernelkernel
bool use_batch_computation
bool use_linadd
bool use_bias
float64_t m_bias
SGVector< float64_tm_alpha
SGVector< int32_t > m_svs
- Protected Attributes inherited from CMachine
float64_t max_train_time
CLabelslabels
ESolverType solver_type
bool m_store_model_features

Additional Inherited Members

- Static Public Member Functions inherited from CKernelMachine
static void * apply_helper (void *p)
- Public Attributes inherited from CSGObject
SGIOio
Parallelparallel
Versionversion
Parameterm_parameters
Parameterm_model_selection_parameters

Constructor & Destructor Documentation

Class default Constructor

Definition at line 17 of file MKLMultiClass.cpp.

CMKLMultiClass ( float64_t  C,
CKernel k,
CLabels lab 
)

Class Constructor commonly used in Shogun Toolbox

Parameters
Cconstant C
kkernel
lablabels

Definition at line 28 of file MKLMultiClass.cpp.

~CMKLMultiClass ( )
virtual

Class default Destructor

Definition at line 40 of file MKLMultiClass.cpp.

CMKLMultiClass ( const CMKLMultiClass cm)
protected

Class Copy Constructor protected to avoid its usage

Definition at line 48 of file MKLMultiClass.cpp.

Member Function Documentation

void addingweightsstep ( const std::vector< float64_t > &  curweights)
protected

adds a constraint to the LP used in MKL

Parameters
curweightsare the current MKL weights

it uses void addingweightsstep( const std::vector<float64_t> & curweights); and float64_t getsumofsignfreealphas();

Definition at line 205 of file MKLMultiClass.cpp.

bool evaluatefinishcriterion ( const int32_t  numberofsilpiterations)
protectedvirtual

checks MKL for convergence

Parameters
numberofsilpiterationsis the number of currently done iterations

Definition at line 129 of file MKLMultiClass.cpp.

virtual EClassifierType get_classifier_type ( )
virtual

get classifier type

Returns
classifier type GMNPMKL

Reimplemented from CMachine.

Definition at line 56 of file MKLMultiClass.h.

float64_t getsquarenormofprimalcoefficients ( const int32_t  ind)
protected

computes the second svm-dependent part used for generating MKL constraints

Parameters
indis the index of the kernel for which to compute $ \|w \|^2 $

Definition at line 289 of file MKLMultiClass.cpp.

float64_t * getsubkernelweights ( int32_t &  numweights)

returns MKL weights for the different kernels

Parameters
numweightsis output parameter, is set to zero if no weights have been computed or to the number of MKL weights which is equal to the number of kernels
Returns
NULL if no weights have been computed or otherwise an array with the weights, caller has to SG_FREE() the output

Definition at line 403 of file MKLMultiClass.cpp.

float64_t getsumofsignfreealphas ( )
protected

computes the first svm-dependent part used for generating MKL constraints it is $ \sum_y b_y^2-\sum_i \sum_{ y | y \neq y_i} \alpha_{iy}(b_{y_i}-b_y-1) $

Definition at line 241 of file MKLMultiClass.cpp.

void initlpsolver ( )
protected

performs some sanity checks (on the provided kernel), inits the GLPK-based LP solver

Definition at line 90 of file MKLMultiClass.cpp.

void initsvm ( )
protected

inits the underlying Multiclass SVM

Definition at line 67 of file MKLMultiClass.cpp.

CMKLMultiClass operator= ( const CMKLMultiClass cm)
protected

Class Assignment operator protected to avoid its usage

Definition at line 58 of file MKLMultiClass.cpp.

void set_max_num_mkliters ( int32_t  maxnum)

sets maximal number of MKL iterations

Parameters
maxnumis the desired maximal number of MKL iterations; when it is reached the MKL terminates irrespective of the MKL progress set it to a nonpositive value in order to turn it off

Definition at line 424 of file MKLMultiClass.cpp.

void set_mkl_epsilon ( float64_t  eps)

sets MKL termination threshold

Parameters
epsis the desired threshold value the termination criterion is the L2 norm between the current MKL weights and their counterpart from the previous iteration

Definition at line 419 of file MKLMultiClass.cpp.

void set_mkl_norm ( float64_t  norm)
virtual

set mkl norm

Parameters
norm

Definition at line 429 of file MKLMultiClass.cpp.

bool train_machine ( CFeatures data = NULL)
protectedvirtual

train Multiclass MKL classifier

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

Reimplemented from CMachine.

Definition at line 325 of file MKLMultiClass.cpp.

Member Data Documentation

the solver wrapper

Definition at line 174 of file MKLMultiClass.h.

int32_t max_num_mkl_iters
protected

maximal number of MKL iterations is set by void set_max_num_mkliters(int32_t maxnum);

Definition at line 187 of file MKLMultiClass.h.

float64_t mkl_eps
protected

MKL termination threshold is set void set_mkl_epsilon(float64_t eps );

Definition at line 183 of file MKLMultiClass.h.

std::vector<float64_t> normweightssquared
protected

stores the term | w_l |^2 ~~~ "alpha o Y K_l Y o alpha"

Definition at line 195 of file MKLMultiClass.h.

float64_t pnorm
protected

MKL norm >=1

Definition at line 191 of file MKLMultiClass.h.

CGMNPSVM* svm
protected

the multiclass svm for fixed MKL weights

Definition at line 170 of file MKLMultiClass.h.

::std::vector< std::vector< float64_t> > weightshistory
protected

stores the last two mkl iteration weights

Definition at line 178 of file MKLMultiClass.h.


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

SHOGUN Machine Learning Toolbox - Documentation