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 SVMLight.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 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)
virtual bool train_machine (CFeatures *data=NULL)

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 120 of file SVMLight.cpp.

CSVMLight ( float64_t  C,
CKernel k,
CLabels lab 
)

constructor

Parameters:
C constant C
k kernel
lab labels

Definition at line 127 of file SVMLight.cpp.

~CSVMLight (  )  [virtual]

Definition at line 158 of file SVMLight.cpp.


Member Function Documentation

void add_to_index ( int32_t *  index,
int32_t  elem 
)

add to index

Parameters:
index index
elem element at index

Definition at line 968 of file SVMLight.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:
docs docs
label label
lin lin
a a
a_old old a
c c
working2dnum working 2D num
active2dnum active 2D num
Returns:
something inty

Definition at line 1239 of file SVMLight.cpp.

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

Definition at line 1678 of file SVMLight.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:
label label
a a
lin lin
c c
totdoc totdoc
maxdiff maximum diff
epsilon_crit_org epsilon crit org
misclassified misclassified
inconsistent inconsistent
active2dnum active 2D num
last_suboptimal_at last suboptimal at
iteration iteration
Returns:
something inty

Definition at line 1356 of file SVMLight.cpp.

void clear_index ( int32_t *  index  ) 

clear index

Parameters:
index index

Definition at line 962 of file SVMLight.cpp.

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

compute index

Parameters:
binfeature binary feature
range range
index 
Returns:
something inty

Definition at line 977 of file SVMLight.cpp.

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

compute kernel

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

Reimplemented in CSVRLight.

Definition at line 611 of file SVMLight.h.

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

helper for compute kernel

Parameters:
p p

Definition at line 109 of file SVMLight.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:
docs docs
label label
exclude_from_eq_const exclude from eq const
eq_target eq target
chosen chosen
active2dnum active 2D num
key key
a a
lin lin
c c
varnum var num
totdoc totdoc
aicache ai cache
qp QP

Definition at line 1166 of file SVMLight.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:
docs docs
label label
exclude_from_eq_const exclude from eq const
eq_target eq target
chosen chosen
active2dnum active 2D num
key key
a a
lin lin
c c
varnum var num
totdoc totdoc
aicache ai cache
qp QP

Definition at line 1034 of file SVMLight.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:
a a
lin lin
c c
eps epsilon
label label
totdoc totdoc
Returns:
something floaty

Reimplemented in CSVRLight.

Definition at line 946 of file SVMLight.cpp.

virtual EClassifierType get_classifier_type (  )  [virtual]

get classifier type

Returns:
classifier type LIGHT

Reimplemented from CMachine.

Reimplemented in CDomainAdaptationSVM, CSVMLightOneClass, and CSVRLight.

Definition at line 253 of file SVMLight.h.

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

Reimplemented from CSVM.

Reimplemented in CDomainAdaptationSVM, and CSVRLight.

Definition at line 641 of file SVMLight.h.

int32_t get_runtime (  ) 

get runtime

Returns:
runtime

Definition at line 284 of file SVMLight.cpp.

void init ( void   ) 

init SVM

Reimplemented from CSGObject.

Definition at line 133 of file SVMLight.cpp.

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

init shrink state

Parameters:
shrink_state shrink state
totdoc totdoc
maxhistory maximum history

Definition at line 1938 of file SVMLight.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 2389 of file SVMLight.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:
docs docs
label label
exclude_from_eq_const exclude from eq const
eq_target eq target
chosen chosen
active2dnum active 2D num
totdoc totdoc
working2dnum working 2D num
varnum var num
a a
lin lin
c c
aicache ai cache
qp QP
epsilon_crit_target epsilon crit target

Definition at line 997 of file SVMLight.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:
docs the docs
label the label
totdoc the totdoc
shrink_state shrink state
inconsistent inconsistent
a a
lin lin
c c
timing_profile timing profile
maxdiff maximum diff
heldout held out
retrain retrain
Returns:
something inty

Definition at line 540 of file SVMLight.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:
label label
a a
shrink_state shrink state
lin lin
c c
totdoc totdoc
iteration iteration
inconsistent inconsistent
docs docs
aicache ai cache
maxdiff maximum diff

Reimplemented in CSVRLight.

Definition at line 2091 of file SVMLight.cpp.

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

helper for reactivate inactive examples linadd

Parameters:
p p

Definition at line 2031 of file SVMLight.cpp.

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

helper for reactivate inactive examples vanilla

Parameters:
p p

Definition at line 2054 of file SVMLight.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:
label label
a a
lin lin
c c
totdoc totdoc
qp_size size of qp
inconsistent inconsistent
active2dnum active 2D num
working2dnum working 2D num
selcrit selcrit
select select
cache_only cache only
key key
chosen chosen
Returns:
something inty

Definition at line 1740 of file SVMLight.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:
label label
a a
lin lin
c c
totdoc totdoc
qp_size size of qp
inconsistent inconsistent
active2dnum active 2D num
working2dnum working 2D num
selcrit selcrit
select select
key key
chosen chosen
iteration iteration
Returns:
something inty

Definition at line 1832 of file SVMLight.cpp.

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

select top n

Parameters:
selcrit selcrit
range range
select select
n n

Definition at line 1902 of file SVMLight.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_state shrink state
active2dnum active 2D num
last_suboptimal_at last suboptimal at
iteration iteration
totdoc totdoc
minshrink minimal shrink
a a
inconsistent inconsistent
c c
lin lin
label label
Returns:
something inty

Definition at line 1970 of file SVMLight.cpp.

void shrink_state_cleanup ( SHRINK_STATE *  shrink_state  ) 

cleanup shrink state

Parameters:
shrink_state shrink state

Definition at line 1959 of file SVMLight.cpp.

void svm_learn (  ) 

learn SVM

Definition at line 292 of file SVMLight.cpp.

bool train_machine ( CFeatures data = NULL  )  [protected, virtual]

train SVM classifier

Parameters:
data training 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.

Reimplemented in CDomainAdaptationSVM, CSVMLightOneClass, and CSVRLight.

Definition at line 175 of file SVMLight.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:
docs docs
label label
active2dnum active 2D num
a a
a_old old a
working2dnum working 2D num
totdoc totdoc
lin lin
aicache ai cache
c c

Reimplemented in CSVRLight.

Definition at line 1417 of file SVMLight.cpp.

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

helper for update linear component linadd

Parameters:
p p

Reimplemented in CSVRLight.

Definition at line 97 of file SVMLight.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:
docs docs
label label
active2dnum active 2D num
a a
a_old old a
working2dnum working 2D num
totdoc totdoc
lin lin
aicache ai cache

Definition at line 1514 of file SVMLight.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:
docs docs
label label
active2dnum active 2D num
a a
a_old old a
working2dnum working 2D num
totdoc totdoc
lin lin
aicache ai cache

Definition at line 1588 of file SVMLight.cpp.

void * update_linear_component_mkl_linadd_helper ( void *  p  )  [static]

helper for update linear component MKL linadd

Parameters:
p p

Definition at line 1665 of file SVMLight.cpp.


Member Data Documentation

int32_t count [protected]

number of iteration

Definition at line 687 of file SVMLight.h.

float64_t* dual [protected]

dual

Definition at line 678 of file SVMLight.h.

int32_t init_iter [protected]

init iter

Definition at line 668 of file SVMLight.h.

float64_t init_margin [protected]

init margin

Definition at line 666 of file SVMLight.h.

LEARN_PARM* learn_parm [protected]

learn parameters

Definition at line 661 of file SVMLight.h.

bool mkl_converged [protected]

mkl converged

Definition at line 693 of file SVMLight.h.

MODEL* model [protected]

model

Definition at line 659 of file SVMLight.h.

float64_t model_b [protected]

model b

Definition at line 672 of file SVMLight.h.

float64_t mymaxdiff [protected]

current alpha gap

Definition at line 689 of file SVMLight.h.

float64_t opt_precision [protected]

opt precision

Definition at line 674 of file SVMLight.h.

int32_t precision_violations [protected]

precision violations

Definition at line 670 of file SVMLight.h.

float64_t* primal [protected]

primal

Definition at line 676 of file SVMLight.h.

bool use_kernel_cache [protected]

if kernel cache is used

Definition at line 691 of file SVMLight.h.

int32_t verbosity [protected]

verbosity level (0-4)

Definition at line 663 of file SVMLight.h.

float64_t* W [protected]

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

Definition at line 685 of file SVMLight.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