CSalzbergWordKernel Class Reference

Inheritance diagram for CSalzbergWordKernel:

Inheritance graph
[legend]

List of all members.


Detailed Description

kernel SalzbergWord

Definition at line 20 of file SalzbergWordKernel.h.


Public Member Functions

 CSalzbergWordKernel (INT size, CPluginEstimate *pie)
 CSalzbergWordKernel (CStringFeatures< WORD > *l, CStringFeatures< WORD > *r, CPluginEstimate *pie)
virtual ~CSalzbergWordKernel ()
void set_prior_probs (DREAL pos_prior_, DREAL neg_prior_)
virtual bool init (CFeatures *l, CFeatures *r)
virtual void cleanup ()
bool load_init (FILE *src)
bool save_init (FILE *dest)
virtual EKernelType get_kernel_type ()
virtual const CHARget_name ()
virtual EFeatureClass get_feature_class ()
virtual EFeatureType get_feature_type ()
template<>
EFeatureType get_feature_type ()
template<>
EFeatureType get_feature_type ()
template<>
EFeatureType get_feature_type ()
template<>
EFeatureType get_feature_type ()
template<>
EFeatureType get_feature_type ()
template<>
EFeatureType get_feature_type ()
template<>
EFeatureType get_feature_type ()
DREAL kernel (INT idx_a, INT idx_b)
void get_kernel_matrix (DREAL **dst, INT *m, INT *n)
virtual DREALget_kernel_matrix_real (int &m, int &n, DREAL *target)
virtual SHORTREALget_kernel_matrix_shortreal (int &m, int &n, SHORTREAL *target)
bool load (CHAR *fname)
bool save (CHAR *fname)
CFeaturesget_lhs ()
CFeaturesget_rhs ()
INT get_num_vec_lhs ()
INT get_num_vec_rhs ()
bool has_features ()
virtual void remove_lhs_and_rhs ()
virtual void remove_lhs ()
virtual void remove_rhs ()
 takes all necessary steps if the rhs is removed from kernel
void set_cache_size (INT size)
int get_cache_size ()
void list_kernel ()
bool has_property (EKernelProperty p)
virtual void clear_normal ()
virtual void add_to_normal (INT vector_idx, DREAL weight)
EOptimizationType get_optimization_type ()
virtual void set_optimization_type (EOptimizationType t)
bool get_is_initialized ()
virtual bool init_optimization (INT count, INT *IDX, DREAL *weights)
virtual bool delete_optimization ()
bool init_optimization_svm (CSVM *svm)
virtual DREAL compute_optimized (INT vector_idx)
virtual void compute_batch (INT num_vec, INT *vec_idx, DREAL *target, INT num_suppvec, INT *IDX, DREAL *alphas, DREAL factor=1.0)
DREAL get_combined_kernel_weight ()
void set_combined_kernel_weight (double nw)
virtual INT get_num_subkernels ()
virtual void compute_by_subkernel (INT vector_idx, DREAL *subkernel_contrib)
virtual const DREALget_subkernel_weights (INT &num_weights)
virtual void set_subkernel_weights (DREAL *weights, INT num_weights)
bool get_precompute_matrix ()
bool get_precompute_subkernel_matrix ()
virtual void set_precompute_matrix (bool flag, bool subkernel_flag)

Static Public Attributes

static CParallel parallel
static CIO io
static CVersion version

Protected Member Functions

DREAL compute (INT idx_a, INT idx_b)
INT compute_index (INT position, WORD symbol)
void set_property (EKernelProperty p)
void unset_property (EKernelProperty p)
void set_is_initialized (bool p_init)
void do_precompute_matrix ()
 matrix precomputation
void init_sqrt_diag (DREAL *v, INT num)

Protected Attributes

CPluginEstimateestimate
DREALmean
DREALvariance
DREALsqrtdiag_lhs
DREALsqrtdiag_rhs
DREALld_mean_lhs
DREALld_mean_rhs
INT num_params
INT num_symbols
DREAL sum_m2_s2
DREAL pos_prior
DREAL neg_prior
bool initialized
INT cache_size
 cache_size in MB
KERNELCACHE_ELEMkernel_matrix
SHORTREALprecomputed_matrix
bool precompute_subkernel_matrix
bool precompute_matrix
CFeatureslhs
 feature vectors to occur on left hand side
CFeaturesrhs
 feature vectors to occur on right hand side
DREAL combined_kernel_weight
bool optimization_initialized
EOptimizationType opt_type
ULONG properties

Constructor & Destructor Documentation

CSalzbergWordKernel::CSalzbergWordKernel ( INT  size,
CPluginEstimate pie 
)

constructor

Parameters:
size cache size
pie the plugin estimate

Definition at line 19 of file SalzbergWordKernel.cpp.

CSalzbergWordKernel::CSalzbergWordKernel ( CStringFeatures< WORD > *  l,
CStringFeatures< WORD > *  r,
CPluginEstimate pie 
)

constructor

Parameters:
l features of left-hand side
r features of right-hand side
pie the plugin estimate

Definition at line 28 of file SalzbergWordKernel.cpp.

CSalzbergWordKernel::~CSalzbergWordKernel (  )  [virtual]

Definition at line 39 of file SalzbergWordKernel.cpp.


Member Function Documentation

void CSalzbergWordKernel::set_prior_probs ( DREAL  pos_prior_,
DREAL  neg_prior_ 
)

set prior probs

Parameters:
pos_prior_ positive prior
neg_prior_ negative prior

Definition at line 47 of file SalzbergWordKernel.h.

bool CSalzbergWordKernel::init ( CFeatures l,
CFeatures r 
) [virtual]

initialize kernel

Parameters:
l features of left-hand side
r features of right-hand side
Returns:
if initializing was successful

Reimplemented from CStringKernel< ST >.

Definition at line 44 of file SalzbergWordKernel.cpp.

void CSalzbergWordKernel::cleanup (  )  [virtual]

clean up kernel

Reimplemented from CKernel.

Definition at line 267 of file SalzbergWordKernel.cpp.

bool CSalzbergWordKernel::load_init ( FILE *  src  )  [virtual]

load kernel init_data

Parameters:
src file to load from
Returns:
if loading was successful

Implements CKernel.

Definition at line 292 of file SalzbergWordKernel.cpp.

bool CSalzbergWordKernel::save_init ( FILE *  dest  )  [virtual]

save kernel init_data

Parameters:
dest file to save to
Returns:
if saving was successful

Implements CKernel.

Definition at line 297 of file SalzbergWordKernel.cpp.

virtual EKernelType CSalzbergWordKernel::get_kernel_type (  )  [virtual]

return what type of kernel we are

Returns:
kernel type SALZBERG

Implements CKernel.

Definition at line 84 of file SalzbergWordKernel.h.

virtual const CHAR* CSalzbergWordKernel::get_name (  )  [virtual]

return the kernel's name

Returns:
name Salzberg

Implements CKernel.

Definition at line 90 of file SalzbergWordKernel.h.

DREAL CSalzbergWordKernel::compute ( INT  idx_a,
INT  idx_b 
) [protected, virtual]

compute kernel function for features a and b idx_{a,b} denote the index of the feature vectors in the corresponding feature object

Parameters:
idx_a index a
idx_b index b
Returns:
computed kernel function at indices a,b

Implements CKernel.

Definition at line 304 of file SalzbergWordKernel.cpp.

INT CSalzbergWordKernel::compute_index ( INT  position,
WORD  symbol 
) [protected]

compute index of given symbol at given position

Parameters:
position position
symbol symbol
Returns:
index

Definition at line 110 of file SalzbergWordKernel.h.

template<class ST>
virtual EFeatureClass CStringKernel< ST >::get_feature_class (  )  [virtual, inherited]

return feature class the kernel can deal with

Returns:
feature class STRING

Implements CKernel.

Definition at line 63 of file StringKernel.h.

template<class ST>
virtual EFeatureType CStringKernel< ST >::get_feature_type (  )  [virtual, inherited]

return feature type the kernel can deal with

Returns:
templated feature type

Implements CKernel.

Reimplemented in CCommUlongStringKernel, CCommWordStringKernel, and CWeightedCommWordStringKernel.

template<>
EFeatureType CStringKernel< DREAL >::get_feature_type (  )  [virtual, inherited]

return feature type the kernel can deal with

abstract base method

Returns:
feature type

Implements CKernel.

Reimplemented in CCommUlongStringKernel, CCommWordStringKernel, and CWeightedCommWordStringKernel.

Definition at line 72 of file StringKernel.h.

template<>
EFeatureType CStringKernel< ULONG >::get_feature_type (  )  [virtual, inherited]

return feature type the kernel can deal with

abstract base method

Returns:
feature type

Implements CKernel.

Reimplemented in CCommUlongStringKernel, CCommWordStringKernel, and CWeightedCommWordStringKernel.

Definition at line 74 of file StringKernel.h.

template<>
EFeatureType CStringKernel< INT >::get_feature_type (  )  [virtual, inherited]

return feature type the kernel can deal with

abstract base method

Returns:
feature type

Implements CKernel.

Reimplemented in CCommUlongStringKernel, CCommWordStringKernel, and CWeightedCommWordStringKernel.

Definition at line 76 of file StringKernel.h.

template<>
EFeatureType CStringKernel< WORD >::get_feature_type (  )  [virtual, inherited]

return feature type the kernel can deal with

abstract base method

Returns:
feature type

Implements CKernel.

Reimplemented in CCommUlongStringKernel, CCommWordStringKernel, and CWeightedCommWordStringKernel.

Definition at line 78 of file StringKernel.h.

template<>
EFeatureType CStringKernel< SHORT >::get_feature_type (  )  [virtual, inherited]

return feature type the kernel can deal with

abstract base method

Returns:
feature type

Implements CKernel.

Reimplemented in CCommUlongStringKernel, CCommWordStringKernel, and CWeightedCommWordStringKernel.

Definition at line 80 of file StringKernel.h.

template<>
EFeatureType CStringKernel< BYTE >::get_feature_type (  )  [virtual, inherited]

return feature type the kernel can deal with

abstract base method

Returns:
feature type

Implements CKernel.

Reimplemented in CCommUlongStringKernel, CCommWordStringKernel, and CWeightedCommWordStringKernel.

Definition at line 82 of file StringKernel.h.

template<>
EFeatureType CStringKernel< CHAR >::get_feature_type (  )  [virtual, inherited]

return feature type the kernel can deal with

abstract base method

Returns:
feature type

Implements CKernel.

Reimplemented in CCommUlongStringKernel, CCommWordStringKernel, and CWeightedCommWordStringKernel.

Definition at line 84 of file StringKernel.h.

DREAL CKernel::kernel ( INT  idx_a,
INT  idx_b 
) [inherited]

get kernel function for lhs feature vector a and rhs feature vector b

Parameters:
idx_a index of feature vector a
idx_b index of feature vector b
Returns:
computed kernel function

Definition at line 48 of file Kernel.h.

void CKernel::get_kernel_matrix ( DREAL **  dst,
INT m,
INT n 
) [inherited]

get kernel matrix

Parameters:
dst destination where matrix will be stored
m dimension m of matrix
n dimension n of matrix

Definition at line 79 of file Kernel.cpp.

DREAL * CKernel::get_kernel_matrix_real ( int &  m,
int &  n,
DREAL target 
) [virtual, inherited]

get kernel matrix real

Parameters:
m dimension m of matrix
n dimension n of matrix
target the kernel matrix
Returns:
the kernel matrix

Definition at line 216 of file Kernel.cpp.

SHORTREAL * CKernel::get_kernel_matrix_shortreal ( int &  m,
int &  n,
SHORTREAL target 
) [virtual, inherited]

get kernel matrix shortreal

Parameters:
m dimension m of matrix
n dimension n of matrix
target target for kernel matrix
Returns:
the kernel matrix

Reimplemented in CCustomKernel.

Definition at line 146 of file Kernel.cpp.

bool CKernel::load ( CHAR fname  )  [inherited]

load the kernel matrix

Parameters:
fname filename to load from
Returns:
if loading was succesful

Definition at line 322 of file Kernel.cpp.

bool CKernel::save ( CHAR fname  )  [inherited]

save kernel matrix

Parameters:
fname filename to save to
Returns:
if saving was successful

Definition at line 327 of file Kernel.cpp.

CFeatures* CKernel::get_lhs (  )  [inherited]

get left-hand side of features used in kernel

Returns:
features of left-hand side

Definition at line 164 of file Kernel.h.

CFeatures* CKernel::get_rhs (  )  [inherited]

get right-hand side of features used in kernel

Returns:
features of right-hand side

Definition at line 170 of file Kernel.h.

INT CKernel::get_num_vec_lhs (  )  [inherited]

get number of vectors of lhs features

Returns:
number of vectors of left-hand side

Definition at line 176 of file Kernel.h.

INT CKernel::get_num_vec_rhs (  )  [inherited]

get number of vectors of rhs features

Returns:
number of vectors of right-hand side

Definition at line 188 of file Kernel.h.

bool CKernel::has_features (  )  [inherited]

test whether features have been assigned to lhs and rhs

Returns:
true if features are assigned

Definition at line 200 of file Kernel.h.

void CKernel::remove_lhs_and_rhs (  )  [virtual, inherited]

remove lhs and rhs from kernel

Definition at line 358 of file Kernel.cpp.

void CKernel::remove_lhs (  )  [virtual, inherited]

void CKernel::remove_rhs (  )  [virtual, inherited]

takes all necessary steps if the rhs is removed from kernel

remove rhs from kernel

Reimplemented in CCombinedKernel, CCommUlongStringKernel, and CCommWordStringKernel.

Definition at line 379 of file Kernel.cpp.

void CKernel::set_cache_size ( INT  size  )  [inherited]

set the size of the kernel cache

Parameters:
size of kernel cache

Definition at line 249 of file Kernel.h.

int CKernel::get_cache_size (  )  [inherited]

return the size of the kernel cache

Returns:
size of kernel cache

Definition at line 259 of file Kernel.h.

void CKernel::list_kernel (  )  [inherited]

list kernel

Definition at line 389 of file Kernel.cpp.

bool CKernel::has_property ( EKernelProperty  p  )  [inherited]

check if kernel has given property

Parameters:
p kernel property
Returns:
if kernel has given property

Definition at line 271 of file Kernel.h.

void CKernel::clear_normal (  )  [virtual, inherited]

for optimizable kernels, i.e. kernels where the weight vector can be computed explicitely (if it fits into memory)

Reimplemented in CCombinedKernel, CCommUlongStringKernel, CCommWordStringKernel, CLinearByteKernel, CLinearKernel, CLinearStringKernel, CLinearWordKernel, CSparseLinearKernel, CWeightedDegreePositionStringKernel, and CWeightedDegreeStringKernel.

Definition at line 578 of file Kernel.cpp.

void CKernel::add_to_normal ( INT  vector_idx,
DREAL  weight 
) [virtual, inherited]

EOptimizationType CKernel::get_optimization_type (  )  [inherited]

get optimization type

Returns:
optimization type

Definition at line 289 of file Kernel.h.

virtual void CKernel::set_optimization_type ( EOptimizationType  t  )  [virtual, inherited]

set optimization type

Parameters:
t optimization type to set

Reimplemented in CCombinedKernel.

Definition at line 295 of file Kernel.h.

bool CKernel::get_is_initialized (  )  [inherited]

check if optimization is initialized

Returns:
if optimization is initialized

Definition at line 301 of file Kernel.h.

bool CKernel::init_optimization ( INT  count,
INT IDX,
DREAL weights 
) [virtual, inherited]

initialize optimization

Parameters:
count count
IDX index
weights weights
Returns:
if initializing was successful

Reimplemented in CCombinedKernel, CCommUlongStringKernel, CCommWordStringKernel, CLinearByteKernel, CLinearKernel, CLinearStringKernel, CLinearWordKernel, CSparseLinearKernel, CWeightedDegreePositionStringKernel, and CWeightedDegreeStringKernel.

Definition at line 550 of file Kernel.cpp.

bool CKernel::delete_optimization (  )  [virtual, inherited]

bool CKernel::init_optimization_svm ( CSVM svm  )  [inherited]

initialize optimization

Parameters:
svm svm model
Returns:
if initializing was successful

Definition at line 644 of file Kernel.cpp.

DREAL CKernel::compute_optimized ( INT  vector_idx  )  [virtual, inherited]

compute optimized

Parameters:
vector_idx index to compute
Returns:
optimized value at given index

Reimplemented in CCombinedKernel, CCommUlongStringKernel, CCommWordStringKernel, CLinearByteKernel, CLinearKernel, CLinearStringKernel, CLinearWordKernel, CSparseLinearKernel, CWeightedCommWordStringKernel, CWeightedDegreePositionStringKernel, and CWeightedDegreeStringKernel.

Definition at line 562 of file Kernel.cpp.

void CKernel::compute_batch ( INT  num_vec,
INT vec_idx,
DREAL target,
INT  num_suppvec,
INT IDX,
DREAL alphas,
DREAL  factor = 1.0 
) [virtual, inherited]

computes output for a batch of examples in an optimized fashion (favorable if kernel supports it, i.e. has KP_BATCHEVALUATION. to the outputvector target (of length num_vec elements) the output for the examples enumerated in vec_idx are added. therefore make sure that it is initialized with ZERO. the following num_suppvec, IDX, alphas arguments are the number of support vectors, their indices and weights

Reimplemented in CCombinedKernel, CWeightedDegreePositionStringKernel, and CWeightedDegreeStringKernel.

Definition at line 568 of file Kernel.cpp.

DREAL CKernel::get_combined_kernel_weight (  )  [inherited]

get combined kernel weight

Returns:
combined kernel weight

Definition at line 346 of file Kernel.h.

void CKernel::set_combined_kernel_weight ( double  nw  )  [inherited]

set combined kernel weight

Parameters:
nw nw

Definition at line 352 of file Kernel.h.

INT CKernel::get_num_subkernels (  )  [virtual, inherited]

get number of subkernels

Returns:
number of subkernels

Reimplemented in CCombinedKernel, CWeightedDegreePositionStringKernel, and CWeightedDegreeStringKernel.

Definition at line 583 of file Kernel.cpp.

void CKernel::compute_by_subkernel ( INT  vector_idx,
DREAL subkernel_contrib 
) [virtual, inherited]

compute by subkernel

Parameters:
vector_idx index
subkernel_contrib subkernel contribution

Reimplemented in CCombinedKernel, CWeightedDegreePositionStringKernel, and CWeightedDegreeStringKernel.

Definition at line 588 of file Kernel.cpp.

const DREAL * CKernel::get_subkernel_weights ( INT num_weights  )  [virtual, inherited]

get subkernel weights

Parameters:
num_weights number of weights will be stored here
Returns:
subkernel weights

Reimplemented in CCombinedKernel, CWeightedDegreePositionStringKernel, and CWeightedDegreeStringKernel.

Definition at line 593 of file Kernel.cpp.

void CKernel::set_subkernel_weights ( DREAL weights,
INT  num_weights 
) [virtual, inherited]

set subkernel weights

Parameters:
weights subkernel weights
num_weights number of weights

Reimplemented in CCombinedKernel, CWeightedDegreePositionStringKernel, and CWeightedDegreeStringKernel.

Definition at line 599 of file Kernel.cpp.

bool CKernel::get_precompute_matrix (  )  [inherited]

get precompute matrix

Returns:
if matrix shall be precomputed

Definition at line 386 of file Kernel.h.

bool CKernel::get_precompute_subkernel_matrix (  )  [inherited]

get precompute subkernel matrix

Returns:
if subkernel matrix shall be precomputed

Definition at line 392 of file Kernel.h.

virtual void CKernel::set_precompute_matrix ( bool  flag,
bool  subkernel_flag 
) [virtual, inherited]

set precompute matrix

Parameters:
flag flag
subkernel_flag subkernel flag

Reimplemented in CCombinedKernel.

Definition at line 399 of file Kernel.h.

void CKernel::set_property ( EKernelProperty  p  )  [protected, inherited]

set property

Parameters:
p kernel property to set

Definition at line 416 of file Kernel.h.

void CKernel::unset_property ( EKernelProperty  p  )  [protected, inherited]

unset property

Parameters:
p kernel property to unset

Definition at line 425 of file Kernel.h.

void CKernel::set_is_initialized ( bool  p_init  )  [protected, inherited]

set is initialized

Parameters:
p_init if optimization shall be set to initialized

Definition at line 434 of file Kernel.h.

void CKernel::do_precompute_matrix (  )  [protected, inherited]

matrix precomputation

Definition at line 606 of file Kernel.cpp.

void CKernel::init_sqrt_diag ( DREAL v,
INT  num 
) [protected, inherited]

initialize sqrt diagonal

Parameters:
v v
num num

Definition at line 634 of file Kernel.cpp.


Member Data Documentation

the plugin estimate

Definition at line 117 of file SalzbergWordKernel.h.

mean

Definition at line 120 of file SalzbergWordKernel.h.

variance

Definition at line 122 of file SalzbergWordKernel.h.

sqrt diagonal of left-hand side

Definition at line 125 of file SalzbergWordKernel.h.

sqrt diagonal of right-hand side

Definition at line 127 of file SalzbergWordKernel.h.

ld mean left-hand side

Definition at line 130 of file SalzbergWordKernel.h.

ld mean right-hand side

Definition at line 132 of file SalzbergWordKernel.h.

number of params

Definition at line 135 of file SalzbergWordKernel.h.

number of symbols

Definition at line 137 of file SalzbergWordKernel.h.

sum m2 s2

Definition at line 139 of file SalzbergWordKernel.h.

positive prior

Definition at line 141 of file SalzbergWordKernel.h.

negative prior

Definition at line 143 of file SalzbergWordKernel.h.

if kernel is initialized

Definition at line 145 of file SalzbergWordKernel.h.

INT CKernel::cache_size [protected, inherited]

cache_size in MB

Definition at line 464 of file Kernel.h.

KERNELCACHE_ELEM* CKernel::kernel_matrix [protected, inherited]

this *COULD* store the whole kernel matrix usually not applicable / faster

Definition at line 470 of file Kernel.h.

SHORTREAL* CKernel::precomputed_matrix [protected, inherited]

precomputed matrix

Definition at line 473 of file Kernel.h.

bool CKernel::precompute_subkernel_matrix [protected, inherited]

if subkernel matrix shall be precomputed

Definition at line 475 of file Kernel.h.

bool CKernel::precompute_matrix [protected, inherited]

if matrix shall be precomputed

Definition at line 477 of file Kernel.h.

CFeatures* CKernel::lhs [protected, inherited]

feature vectors to occur on left hand side

Definition at line 480 of file Kernel.h.

CFeatures* CKernel::rhs [protected, inherited]

feature vectors to occur on right hand side

Definition at line 482 of file Kernel.h.

DREAL CKernel::combined_kernel_weight [protected, inherited]

combined kernel weight

Definition at line 485 of file Kernel.h.

bool CKernel::optimization_initialized [protected, inherited]

if optimization is initialized

Definition at line 488 of file Kernel.h.

EOptimizationType CKernel::opt_type [protected, inherited]

optimization type (currently FASTBUTMEMHUNGRY and SLOWBUTMEMEFFICIENT)

Definition at line 492 of file Kernel.h.

ULONG CKernel::properties [protected, inherited]

properties

Definition at line 495 of file Kernel.h.

CParallel CSGObject::parallel [static, inherited]

Definition at line 105 of file SGObject.h.

CIO CSGObject::io [static, inherited]

Definition at line 106 of file SGObject.h.

CVersion CSGObject::version [static, inherited]

Definition at line 107 of file SGObject.h.


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

SHOGUN Machine Learning Toolbox - Documentation