SHOGUN v0.9.3
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes
CSVMLight Class Reference

Detailed Description

class SVMlight

Definition at line 231 of file SVM_light.h.

Inheritance diagram for CSVMLight:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 CSVMLight ()
 CSVMLight (float64_t C, CKernel *k, CLabels *lab)
virtual ~CSVMLight ()
void init ()
virtual bool train (CFeatures *data=NULL)
virtual EClassifierType get_classifier_type ()
int32_t get_runtime ()
void svm_learn ()
int32_t optimize_to_convergence (int32_t *docs, int32_t *label, int32_t totdoc, SHRINK_STATE *shrink_state, int32_t *inconsistent, float64_t *a, float64_t *lin, float64_t *c, TIMING *timing_profile, float64_t *maxdiff, int32_t heldout, int32_t retrain)
virtual float64_t compute_objective_function (float64_t *a, float64_t *lin, float64_t *c, float64_t *eps, int32_t *label, int32_t totdoc)
void clear_index (int32_t *index)
void add_to_index (int32_t *index, int32_t elem)
int32_t compute_index (int32_t *binfeature, int32_t range, int32_t *index)
void optimize_svm (int32_t *docs, int32_t *label, int32_t *exclude_from_eq_const, float64_t eq_target, int32_t *chosen, int32_t *active2dnum, int32_t totdoc, int32_t *working2dnum, int32_t varnum, float64_t *a, float64_t *lin, float64_t *c, float64_t *aicache, QP *qp, float64_t *epsilon_crit_target)
void compute_matrices_for_optimization (int32_t *docs, int32_t *label, int32_t *exclude_from_eq_const, float64_t eq_target, int32_t *chosen, int32_t *active2dnum, int32_t *key, float64_t *a, float64_t *lin, float64_t *c, int32_t varnum, int32_t totdoc, float64_t *aicache, QP *qp)
void compute_matrices_for_optimization_parallel (int32_t *docs, int32_t *label, int32_t *exclude_from_eq_const, float64_t eq_target, int32_t *chosen, int32_t *active2dnum, int32_t *key, float64_t *a, float64_t *lin, float64_t *c, int32_t varnum, int32_t totdoc, float64_t *aicache, QP *qp)
int32_t calculate_svm_model (int32_t *docs, int32_t *label, float64_t *lin, float64_t *a, float64_t *a_old, float64_t *c, int32_t *working2dnum, int32_t *active2dnum)
int32_t check_optimality (int32_t *label, float64_t *a, float64_t *lin, float64_t *c, int32_t totdoc, float64_t *maxdiff, float64_t epsilon_crit_org, int32_t *misclassified, int32_t *inconsistent, int32_t *active2dnum, int32_t *last_suboptimal_at, int32_t iteration)
virtual void update_linear_component (int32_t *docs, int32_t *label, int32_t *active2dnum, float64_t *a, float64_t *a_old, int32_t *working2dnum, int32_t totdoc, float64_t *lin, float64_t *aicache, float64_t *c)
void update_linear_component_mkl (int32_t *docs, int32_t *label, int32_t *active2dnum, float64_t *a, float64_t *a_old, int32_t *working2dnum, int32_t totdoc, float64_t *lin, float64_t *aicache)
void update_linear_component_mkl_linadd (int32_t *docs, int32_t *label, int32_t *active2dnum, float64_t *a, float64_t *a_old, int32_t *working2dnum, int32_t totdoc, float64_t *lin, float64_t *aicache)
void call_mkl_callback (float64_t *a, int32_t *label, float64_t *lin)
int32_t select_next_qp_subproblem_grad (int32_t *label, float64_t *a, float64_t *lin, float64_t *c, int32_t totdoc, int32_t qp_size, int32_t *inconsistent, int32_t *active2dnum, int32_t *working2dnum, float64_t *selcrit, int32_t *select, int32_t cache_only, int32_t *key, int32_t *chosen)
int32_t select_next_qp_subproblem_rand (int32_t *label, float64_t *a, float64_t *lin, float64_t *c, int32_t totdoc, int32_t qp_size, int32_t *inconsistent, int32_t *active2dnum, int32_t *working2dnum, float64_t *selcrit, int32_t *select, int32_t *key, int32_t *chosen, int32_t iteration)
void select_top_n (float64_t *selcrit, int32_t range, int32_t *select, int32_t n)
void init_shrink_state (SHRINK_STATE *shrink_state, int32_t totdoc, int32_t maxhistory)
void shrink_state_cleanup (SHRINK_STATE *shrink_state)
int32_t shrink_problem (SHRINK_STATE *shrink_state, int32_t *active2dnum, int32_t *last_suboptimal_at, int32_t iteration, int32_t totdoc, int32_t minshrink, float64_t *a, int32_t *inconsistent, float64_t *c, float64_t *lin, int *label)
virtual void reactivate_inactive_examples (int32_t *label, float64_t *a, SHRINK_STATE *shrink_state, float64_t *lin, float64_t *c, int32_t totdoc, int32_t iteration, int32_t *inconsistent, int32_t *docs, float64_t *aicache, float64_t *maxdiff)

Static Public Member Functions

static void * update_linear_component_mkl_linadd_helper (void *p)

Protected Member Functions

virtual float64_t compute_kernel (int32_t i, int32_t j)
virtual const char * get_name () const
float64_toptimize_qp (QP *qp, float64_t *epsilon_crit, int32_t nx, float64_t *threshold, int32_t &svm_maxqpsize)

Static Protected Member Functions

static void * compute_kernel_helper (void *p)
static void * update_linear_component_linadd_helper (void *p)
static void * reactivate_inactive_examples_vanilla_helper (void *p)
static void * reactivate_inactive_examples_linadd_helper (void *p)

Protected Attributes

MODEL * model
LEARN_PARM * learn_parm
int32_t verbosity
float64_t init_margin
int32_t init_iter
int32_t precision_violations
float64_t model_b
float64_t opt_precision
float64_tprimal
float64_tdual
float64_tW
int32_t count
float64_t mymaxdiff
bool use_kernel_cache
bool mkl_converged

Constructor & Destructor Documentation

CSVMLight ( )

default constructor

Definition at line 126 of file SVM_light.cpp.

CSVMLight ( float64_t  C,
CKernel k,
CLabels lab 
)

constructor

Parameters:
Cconstant C
kkernel
lablabels

Definition at line 133 of file SVM_light.cpp.

~CSVMLight ( ) [virtual]

Definition at line 164 of file SVM_light.cpp.


Member Function Documentation

void add_to_index ( int32_t *  index,
int32_t  elem 
)

add to index

Parameters:
indexindex
elemelement at index

Definition at line 981 of file SVM_light.cpp.

int32_t calculate_svm_model ( int32_t *  docs,
int32_t *  label,
float64_t lin,
float64_t a,
float64_t a_old,
float64_t c,
int32_t *  working2dnum,
int32_t *  active2dnum 
)

calculate SVM model

Parameters:
docsdocs
labellabel
linlin
aa
a_oldold a
cc
working2dnumworking 2D num
active2dnumactive 2D num
Returns:
something inty

Definition at line 1252 of file SVM_light.cpp.

void call_mkl_callback ( float64_t a,
int32_t *  label,
float64_t lin 
)

Definition at line 1691 of file SVM_light.cpp.

int32_t check_optimality ( int32_t *  label,
float64_t a,
float64_t lin,
float64_t c,
int32_t  totdoc,
float64_t maxdiff,
float64_t  epsilon_crit_org,
int32_t *  misclassified,
int32_t *  inconsistent,
int32_t *  active2dnum,
int32_t *  last_suboptimal_at,
int32_t  iteration 
)

check optimality

Parameters:
labellabel
aa
linlin
cc
totdoctotdoc
maxdiffmaximum diff
epsilon_crit_orgepsilon crit org
misclassifiedmisclassified
inconsistentinconsistent
active2dnumactive 2D num
last_suboptimal_atlast suboptimal at
iterationiteration
Returns:
something inty

Definition at line 1369 of file SVM_light.cpp.

void clear_index ( int32_t *  index)

clear index

Parameters:
indexindex

Definition at line 975 of file SVM_light.cpp.

int32_t compute_index ( int32_t *  binfeature,
int32_t  range,
int32_t *  index 
)

compute index

Parameters:
binfeaturebinary feature
rangerange
index
Returns:
something inty

Definition at line 990 of file SVM_light.cpp.

virtual float64_t compute_kernel ( int32_t  i,
int32_t  j 
) [protected, virtual]

compute kernel

Parameters:
iat index i
jat index j
Returns:
computed kernel item at index i, j

Reimplemented in CSVRLight.

Definition at line 621 of file SVM_light.h.

void * compute_kernel_helper ( void *  p) [static, protected]

helper for compute kernel

Parameters:
pp

Definition at line 115 of file SVM_light.cpp.

void compute_matrices_for_optimization ( int32_t *  docs,
int32_t *  label,
int32_t *  exclude_from_eq_const,
float64_t  eq_target,
int32_t *  chosen,
int32_t *  active2dnum,
int32_t *  key,
float64_t a,
float64_t lin,
float64_t c,
int32_t  varnum,
int32_t  totdoc,
float64_t aicache,
QP *  qp 
)

compute matrices for optimization

Parameters:
docsdocs
labellabel
exclude_from_eq_constexclude from eq const
eq_targeteq target
chosenchosen
active2dnumactive 2D num
keykey
aa
linlin
cc
varnumvar num
totdoctotdoc
aicacheai cache
qpQP

Definition at line 1179 of file SVM_light.cpp.

void compute_matrices_for_optimization_parallel ( int32_t *  docs,
int32_t *  label,
int32_t *  exclude_from_eq_const,
float64_t  eq_target,
int32_t *  chosen,
int32_t *  active2dnum,
int32_t *  key,
float64_t a,
float64_t lin,
float64_t c,
int32_t  varnum,
int32_t  totdoc,
float64_t aicache,
QP *  qp 
)

compute matrices for optimization in parallel

Parameters:
docsdocs
labellabel
exclude_from_eq_constexclude from eq const
eq_targeteq target
chosenchosen
active2dnumactive 2D num
keykey
aa
linlin
cc
varnumvar num
totdoctotdoc
aicacheai cache
qpQP

Definition at line 1047 of file SVM_light.cpp.

float64_t compute_objective_function ( float64_t a,
float64_t lin,
float64_t c,
float64_t eps,
int32_t *  label,
int32_t  totdoc 
) [virtual]

compute objective function

Parameters:
aa
linlin
cc
epsepsilon
labellabel
totdoctotdoc
Returns:
something floaty

Reimplemented in CSVRLight.

Definition at line 959 of file SVM_light.cpp.

virtual EClassifierType get_classifier_type ( ) [virtual]

get classifier type

Returns:
classifier type LIGHT

Reimplemented from CClassifier.

Reimplemented in CDomainAdaptationSVM, and CSVRLight.

Definition at line 263 of file SVM_light.h.

virtual const char* get_name ( ) const [protected, virtual]
Returns:
object name

Reimplemented from CSVM.

Reimplemented in CDomainAdaptationSVM, and CSVRLight.

Definition at line 651 of file SVM_light.h.

int32_t get_runtime ( )

get runtime

Returns:
runtime

Definition at line 290 of file SVM_light.cpp.

void init ( )

init SVM

Definition at line 139 of file SVM_light.cpp.

void init_shrink_state ( SHRINK_STATE *  shrink_state,
int32_t  totdoc,
int32_t  maxhistory 
)

init shrink state

Parameters:
shrink_stateshrink state
totdoctotdoc
maxhistorymaximum history

Definition at line 1951 of file SVM_light.cpp.

float64_t * optimize_qp ( QP *  qp,
float64_t epsilon_crit,
int32_t  nx,
float64_t threshold,
int32_t &  svm_maxqpsize 
) [protected]

Definition at line 2402 of file SVM_light.cpp.

void optimize_svm ( int32_t *  docs,
int32_t *  label,
int32_t *  exclude_from_eq_const,
float64_t  eq_target,
int32_t *  chosen,
int32_t *  active2dnum,
int32_t  totdoc,
int32_t *  working2dnum,
int32_t  varnum,
float64_t a,
float64_t lin,
float64_t c,
float64_t aicache,
QP *  qp,
float64_t epsilon_crit_target 
)

optimise SVM

Parameters:
docsdocs
labellabel
exclude_from_eq_constexclude from eq const
eq_targeteq target
chosenchosen
active2dnumactive 2D num
totdoctotdoc
working2dnumworking 2D num
varnumvar num
aa
linlin
cc
aicacheai cache
qpQP
epsilon_crit_targetepsilon crit target

Definition at line 1010 of file SVM_light.cpp.

int32_t optimize_to_convergence ( int32_t *  docs,
int32_t *  label,
int32_t  totdoc,
SHRINK_STATE *  shrink_state,
int32_t *  inconsistent,
float64_t a,
float64_t lin,
float64_t c,
TIMING *  timing_profile,
float64_t maxdiff,
int32_t  heldout,
int32_t  retrain 
)

optimize to convergence

Parameters:
docsthe docs
labelthe label
totdocthe totdoc
shrink_stateshrink state
inconsistentinconsistent
aa
linlin
cc
timing_profiletiming profile
maxdiffmaximum diff
heldoutheld out
retrainretrain
Returns:
something inty

Definition at line 549 of file SVM_light.cpp.

void reactivate_inactive_examples ( int32_t *  label,
float64_t a,
SHRINK_STATE *  shrink_state,
float64_t lin,
float64_t c,
int32_t  totdoc,
int32_t  iteration,
int32_t *  inconsistent,
int32_t *  docs,
float64_t aicache,
float64_t maxdiff 
) [virtual]

reactivate inactive examples

Parameters:
labellabel
aa
shrink_stateshrink state
linlin
cc
totdoctotdoc
iterationiteration
inconsistentinconsistent
docsdocs
aicacheai cache
maxdiffmaximum diff

Reimplemented in CSVRLight.

Definition at line 2104 of file SVM_light.cpp.

void * reactivate_inactive_examples_linadd_helper ( void *  p) [static, protected]

helper for reactivate inactive examples linadd

Parameters:
pp

Definition at line 2044 of file SVM_light.cpp.

void * reactivate_inactive_examples_vanilla_helper ( void *  p) [static, protected]

helper for reactivate inactive examples vanilla

Parameters:
pp

Definition at line 2067 of file SVM_light.cpp.

int32_t select_next_qp_subproblem_grad ( int32_t *  label,
float64_t a,
float64_t lin,
float64_t c,
int32_t  totdoc,
int32_t  qp_size,
int32_t *  inconsistent,
int32_t *  active2dnum,
int32_t *  working2dnum,
float64_t selcrit,
int32_t *  select,
int32_t  cache_only,
int32_t *  key,
int32_t *  chosen 
)

select next qp subproblem grad

Parameters:
labellabel
aa
linlin
cc
totdoctotdoc
qp_sizesize of qp
inconsistentinconsistent
active2dnumactive 2D num
working2dnumworking 2D num
selcritselcrit
selectselect
cache_onlycache only
keykey
chosenchosen
Returns:
something inty

Definition at line 1753 of file SVM_light.cpp.

int32_t select_next_qp_subproblem_rand ( int32_t *  label,
float64_t a,
float64_t lin,
float64_t c,
int32_t  totdoc,
int32_t  qp_size,
int32_t *  inconsistent,
int32_t *  active2dnum,
int32_t *  working2dnum,
float64_t selcrit,
int32_t *  select,
int32_t *  key,
int32_t *  chosen,
int32_t  iteration 
)

select next qp subproblem rand

Parameters:
labellabel
aa
linlin
cc
totdoctotdoc
qp_sizesize of qp
inconsistentinconsistent
active2dnumactive 2D num
working2dnumworking 2D num
selcritselcrit
selectselect
keykey
chosenchosen
iterationiteration
Returns:
something inty

Definition at line 1845 of file SVM_light.cpp.

void select_top_n ( float64_t selcrit,
int32_t  range,
int32_t *  select,
int32_t  n 
)

select top n

Parameters:
selcritselcrit
rangerange
selectselect
nn

Definition at line 1915 of file SVM_light.cpp.

int32_t shrink_problem ( SHRINK_STATE *  shrink_state,
int32_t *  active2dnum,
int32_t *  last_suboptimal_at,
int32_t  iteration,
int32_t  totdoc,
int32_t  minshrink,
float64_t a,
int32_t *  inconsistent,
float64_t c,
float64_t lin,
int *  label 
)

shrink problem

Parameters:
shrink_stateshrink state
active2dnumactive 2D num
last_suboptimal_atlast suboptimal at
iterationiteration
totdoctotdoc
minshrinkminimal shrink
aa
inconsistentinconsistent
cc
linlin
labellabel
Returns:
something inty

Definition at line 1983 of file SVM_light.cpp.

void shrink_state_cleanup ( SHRINK_STATE *  shrink_state)

cleanup shrink state

Parameters:
shrink_stateshrink state

Definition at line 1972 of file SVM_light.cpp.

void svm_learn ( )

learn SVM

Definition at line 298 of file SVM_light.cpp.

bool train ( CFeatures data = NULL) [virtual]

train SVM 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 CClassifier.

Reimplemented in CDomainAdaptationSVM, and CSVRLight.

Definition at line 181 of file SVM_light.cpp.

void update_linear_component ( int32_t *  docs,
int32_t *  label,
int32_t *  active2dnum,
float64_t a,
float64_t a_old,
int32_t *  working2dnum,
int32_t  totdoc,
float64_t lin,
float64_t aicache,
float64_t c 
) [virtual]

update linear component

Parameters:
docsdocs
labellabel
active2dnumactive 2D num
aa
a_oldold a
working2dnumworking 2D num
totdoctotdoc
linlin
aicacheai cache
cc

Reimplemented in CSVRLight.

Definition at line 1430 of file SVM_light.cpp.

void * update_linear_component_linadd_helper ( void *  p) [static, protected]

helper for update linear component linadd

Parameters:
pp

Reimplemented in CSVRLight.

Definition at line 103 of file SVM_light.cpp.

void update_linear_component_mkl ( int32_t *  docs,
int32_t *  label,
int32_t *  active2dnum,
float64_t a,
float64_t a_old,
int32_t *  working2dnum,
int32_t  totdoc,
float64_t lin,
float64_t aicache 
)

update linear component MKL

Parameters:
docsdocs
labellabel
active2dnumactive 2D num
aa
a_oldold a
working2dnumworking 2D num
totdoctotdoc
linlin
aicacheai cache

Definition at line 1527 of file SVM_light.cpp.

void update_linear_component_mkl_linadd ( int32_t *  docs,
int32_t *  label,
int32_t *  active2dnum,
float64_t a,
float64_t a_old,
int32_t *  working2dnum,
int32_t  totdoc,
float64_t lin,
float64_t aicache 
)

update linear component MKL

Parameters:
docsdocs
labellabel
active2dnumactive 2D num
aa
a_oldold a
working2dnumworking 2D num
totdoctotdoc
linlin
aicacheai cache

Definition at line 1601 of file SVM_light.cpp.

void * update_linear_component_mkl_linadd_helper ( void *  p) [static]

helper for update linear component MKL linadd

Parameters:
pp

Definition at line 1678 of file SVM_light.cpp.


Member Data Documentation

int32_t count [protected]

number of iteration

Definition at line 763 of file SVM_light.h.

float64_t* dual [protected]

dual

Definition at line 754 of file SVM_light.h.

int32_t init_iter [protected]

init iter

Definition at line 744 of file SVM_light.h.

float64_t init_margin [protected]

init margin

Definition at line 742 of file SVM_light.h.

LEARN_PARM* learn_parm [protected]

learn parameters

Definition at line 737 of file SVM_light.h.

bool mkl_converged [protected]

mkl converged

Definition at line 769 of file SVM_light.h.

MODEL* model [protected]

model

Definition at line 735 of file SVM_light.h.

float64_t model_b [protected]

model b

Definition at line 748 of file SVM_light.h.

float64_t mymaxdiff [protected]

current alpha gap

Definition at line 765 of file SVM_light.h.

float64_t opt_precision [protected]

opt precision

Definition at line 750 of file SVM_light.h.

int32_t precision_violations [protected]

precision violations

Definition at line 746 of file SVM_light.h.

float64_t* primal [protected]

primal

Definition at line 752 of file SVM_light.h.

bool use_kernel_cache [protected]

if kernel cache is used

Definition at line 767 of file SVM_light.h.

int32_t verbosity [protected]

verbosity level (0-4)

Definition at line 739 of file SVM_light.h.

float64_t* W [protected]

Matrix that stores the contribution by each kernel for each example (for current alphas)

Definition at line 761 of file SVM_light.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