The Weighted Degree String kernel.
The WD kernel of order d compares two sequences \({\bf x}\) and \({\bf x'}\) of length L by summing all contributions of k-mer matches of lengths \(k\in\{1,\dots,d\}\), weighted by coefficients \(\beta_k\). It is defined as
\[ k({\bf x},{\bf x'})=\sum_{k=1}^d\beta_k\sum_{l=1}^{L-k+1}I({\bf u}_{k,l}({\bf x})={\bf u}_{k,l}({\bf x'})). \]
Here, \({\bf u}_{k,l}({\bf x})\) is the string of length k starting at position l of the sequence \({\bf x}\) and \(I(\cdot)\) is the indicator function which evaluates to 1 when its argument is true and to 0 otherwise.
在文件 WeightedDegreeStringKernel.h 第 55 行定义.
|
| CWeightedDegreeStringKernel () |
|
| CWeightedDegreeStringKernel (int32_t degree, EWDKernType type=E_WD) |
|
| CWeightedDegreeStringKernel (SGVector< float64_t > weights) |
|
| CWeightedDegreeStringKernel (CStringFeatures< char > *l, CStringFeatures< char > *r, int32_t degree) |
|
virtual | ~CWeightedDegreeStringKernel () |
|
virtual bool | init (CFeatures *l, CFeatures *r) |
|
virtual void | cleanup () |
|
EWDKernType | get_type () const |
|
virtual EKernelType | get_kernel_type () |
|
virtual const char * | get_name () const |
|
virtual bool | init_optimization (int32_t count, int32_t *IDX, float64_t *alphas) |
|
virtual bool | init_optimization (int32_t count, int32_t *IDX, float64_t *alphas, int32_t tree_num) |
|
virtual bool | delete_optimization () |
|
virtual float64_t | compute_optimized (int32_t idx) |
|
virtual void | compute_batch (int32_t num_vec, int32_t *vec_idx, float64_t *target, int32_t num_suppvec, int32_t *IDX, float64_t *alphas, float64_t factor=1.0) |
|
virtual void | clear_normal () |
|
virtual void | add_to_normal (int32_t idx, float64_t weight) |
|
virtual int32_t | get_num_subkernels () |
|
void | compute_by_subkernel (int32_t idx, float64_t *subkernel_contrib) |
|
const float64_t * | get_subkernel_weights (int32_t &num_weights) |
|
virtual void | set_subkernel_weights (SGVector< float64_t > w) |
|
virtual bool | set_normalizer (CKernelNormalizer *normalizer_) |
|
float64_t * | compute_abs_weights (int32_t &len) |
|
void | compute_by_tree (int32_t idx, float64_t *LevelContrib) |
|
bool | is_tree_initialized () |
|
float64_t * | get_degree_weights (int32_t &d, int32_t &len) |
|
float64_t * | get_weights (int32_t &num_weights) |
|
float64_t * | get_position_weights (int32_t &len) |
|
bool | set_wd_weights_by_type (EWDKernType type) |
|
void | set_wd_weights (SGVector< float64_t > new_weights) |
|
bool | set_weights (SGMatrix< float64_t > new_weights) |
|
bool | set_position_weights (float64_t *pws, int32_t len) |
|
bool | init_block_weights () |
|
bool | init_block_weights_from_wd () |
|
bool | init_block_weights_from_wd_external () |
|
bool | init_block_weights_const () |
|
bool | init_block_weights_linear () |
|
bool | init_block_weights_sqpoly () |
|
bool | init_block_weights_cubicpoly () |
|
bool | init_block_weights_exp () |
|
bool | init_block_weights_log () |
|
bool | delete_position_weights () |
|
bool | set_max_mismatch (int32_t max) |
|
int32_t | get_max_mismatch () const |
|
bool | set_degree (int32_t deg) |
|
int32_t | get_degree () const |
|
bool | set_use_block_computation (bool block) |
|
bool | get_use_block_computation () |
|
bool | set_mkl_stepsize (int32_t step) |
|
int32_t | get_mkl_stepsize () |
|
bool | set_which_degree (int32_t which) |
|
int32_t | get_which_degree () |
|
virtual EFeatureClass | get_feature_class () |
|
virtual EFeatureType | get_feature_type () |
|
float64_t | kernel (int32_t idx_a, int32_t idx_b) |
|
SGMatrix< float64_t > | get_kernel_matrix () |
|
template<class T > |
SGMatrix< T > | get_kernel_matrix () |
|
SGVector< float64_t > | get_kernel_diagonal (SGVector< float64_t > preallocated=SGVector< float64_t >()) |
|
virtual SGVector< float64_t > | get_kernel_col (int32_t j) |
|
virtual SGVector< float64_t > | get_kernel_row (int32_t i) |
|
virtual float64_t | sum_symmetric_block (index_t block_begin, index_t block_size, bool no_diag=true) |
|
virtual float64_t | sum_block (index_t block_begin_row, index_t block_begin_col, index_t block_size_row, index_t block_size_col, bool no_diag=false) |
|
virtual SGVector< float64_t > | row_wise_sum_symmetric_block (index_t block_begin, index_t block_size, bool no_diag=true) |
|
virtual SGMatrix< float64_t > | row_wise_sum_squared_sum_symmetric_block (index_t block_begin, index_t block_size, bool no_diag=true) |
|
virtual SGVector< float64_t > | row_col_wise_sum_block (index_t block_begin_row, index_t block_begin_col, index_t block_size_row, index_t block_size_col, bool no_diag=false) |
|
virtual CKernelNormalizer * | get_normalizer () |
|
virtual bool | init_normalizer () |
|
void | load (CFile *loader) |
|
void | save (CFile *writer) |
|
CFeatures * | get_lhs () |
|
CFeatures * | get_rhs () |
|
virtual int32_t | get_num_vec_lhs () |
|
virtual int32_t | get_num_vec_rhs () |
|
virtual bool | has_features () |
|
bool | get_lhs_equals_rhs () |
|
virtual void | remove_lhs_and_rhs () |
|
virtual void | remove_rhs () |
| takes all necessary steps if the rhs is removed from kernel 更多...
|
|
void | set_cache_size (int32_t size) |
|
int32_t | get_cache_size () |
|
void | list_kernel () |
|
bool | has_property (EKernelProperty p) |
|
EOptimizationType | get_optimization_type () |
|
virtual void | set_optimization_type (EOptimizationType t) |
|
bool | get_is_initialized () |
|
bool | init_optimization_svm (CSVM *svm) |
|
float64_t | get_combined_kernel_weight () |
|
void | set_combined_kernel_weight (float64_t nw) |
|
virtual SGVector< float64_t > | get_subkernel_weights () |
|
virtual SGMatrix< float64_t > | get_parameter_gradient (const TParameter *param, index_t index=-1) |
|
virtual SGVector< float64_t > | get_parameter_gradient_diagonal (const TParameter *param, index_t index=-1) |
|
virtual CSGObject * | shallow_copy () const |
|
virtual CSGObject * | deep_copy () const |
|
virtual bool | is_generic (EPrimitiveType *generic) const |
|
template<class T > |
void | set_generic () |
|
template<> |
void | set_generic () |
|
template<> |
void | set_generic () |
|
template<> |
void | set_generic () |
|
template<> |
void | set_generic () |
|
template<> |
void | set_generic () |
|
template<> |
void | set_generic () |
|
template<> |
void | set_generic () |
|
template<> |
void | set_generic () |
|
template<> |
void | set_generic () |
|
template<> |
void | set_generic () |
|
template<> |
void | set_generic () |
|
template<> |
void | set_generic () |
|
template<> |
void | set_generic () |
|
template<> |
void | set_generic () |
|
template<> |
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) |
|
SGIO * | get_global_io () |
|
void | set_global_parallel (Parallel *parallel) |
|
Parallel * | get_global_parallel () |
|
void | set_global_version (Version *version) |
|
Version * | get_global_version () |
|
SGStringList< char > | get_modelsel_names () |
|
void | print_modsel_params () |
|
char * | get_modsel_param_descr (const char *param_name) |
|
index_t | get_modsel_param_index (const char *param_name) |
|
void | build_gradient_parameter_dictionary (CMap< TParameter *, CSGObject * > *dict) |
|
virtual void | update_parameter_hash () |
|
virtual bool | parameter_hash_changed () |
|
virtual bool | equals (CSGObject *other, float64_t accuracy=0.0, bool tolerant=false) |
|
virtual CSGObject * | clone () |
|
|
void | create_empty_tries () |
|
void | add_example_to_tree (int32_t idx, float64_t weight) |
|
void | add_example_to_single_tree (int32_t idx, float64_t weight, int32_t tree_num) |
|
void | add_example_to_tree_mismatch (int32_t idx, float64_t weight) |
|
void | add_example_to_single_tree_mismatch (int32_t idx, float64_t weight, int32_t tree_num) |
|
float64_t | compute_by_tree (int32_t idx) |
|
float64_t | compute (int32_t idx_a, int32_t idx_b) |
|
float64_t | compute_with_mismatch (char *avec, int32_t alen, char *bvec, int32_t blen) |
|
float64_t | compute_without_mismatch (char *avec, int32_t alen, char *bvec, int32_t blen) |
|
float64_t | compute_without_mismatch_matrix (char *avec, int32_t alen, char *bvec, int32_t blen) |
|
float64_t | compute_using_block (char *avec, int32_t alen, char *bvec, int32_t blen) |
|
virtual void | remove_lhs () |
|
void | set_property (EKernelProperty p) |
|
void | unset_property (EKernelProperty p) |
|
void | set_is_initialized (bool p_init) |
|
int32_t | compute_row_start (int64_t offs, int32_t n, bool symmetric) |
|
virtual void | load_serializable_post () throw (ShogunException) |
|
virtual void | save_serializable_pre () throw (ShogunException) |
|
virtual void | save_serializable_post () throw (ShogunException) |
|
virtual void | register_params () |
|
virtual void | load_serializable_pre () throw (ShogunException) |
|
Computes row-wise/col-wise sum of kernel values. This method is useful while computing statistical estimation of mean/variance over kernel values but the kernel matrix is too huge to be fit inside memory.
- 参数
-
block_begin_row | the row index at which the block starts |
block_begin_col | the col index at which the block starts |
block_size_row | the number of rows in the block |
block_size_col | the number of cols in the block |
For Example, block_begin_row 0, block_begin_col 4 and block_size_row 5, block_size_col 6 represents the block that starts at index (0,4) in the kernel matrix and goes upto (0+5-1,4+6-1) i.e. (4,9) both inclusive
- 参数
-
no_diag | if true (default is false), the diagonal elements are excluded from the row/col-wise sum, provided that block_size_row and block_size_col are same (i.e. the block is square). Otherwise, these are always added |
- 返回
- a vector whose first block_size_row entries contain row-wise sum of kernel values computed as
\[ v[i]=\sum_{j}k(i+\text{block-begin-row}, j+\text{block-begin-col}) \]
and rest block_size_col entries col-wise sum of kernel values computed as
\[ v[\text{block-size-row}+j]=\sum_{i}k(i+\text{block-begin-row}, j+\text{block-begin-col}) \]
where \(i\in[0,\text{block-size-row}-1]\) and \(j\in[0,\text{block-size-col}-1]\)
在文件 Kernel.cpp 第 749 行定义.
Computes row-wise/col-wise sum and squared sum of kernel values from a symmetric part of the kernel matrix that always is supposed to contain the main upper diagonal. This method is useful while computing statistical estimation of mean/variance over kernel values but the kernel matrix is too huge to be fit inside memory.
- 参数
-
block_begin | the row and col index at which the block starts |
block_size | the number of rows and cols in the block |
For Example, block_begin 4 and block_size 5 represents the block that starts at index (4,4) in the kernel matrix and goes upto (4+5-1,4+5-1) i.e. (8,8) both inclusive
- 参数
-
no_diag | if true (default), the diagonal elements are excluded from the row/col-wise sum |
- 返回
- a matrix whose first column contains the row-wise sum of kernel values computed as
\[ v_0[i]=\sum_{j}k(i+\text{block-begin}, j+\text{block-begin}) \]
and second column contains the row-wise sum of squared kernel values
\[ v_1[i]=\sum_{j}^k^2(i+\text{block-begin}, j+\text{block-begin}) \]
where \(i,j\in[0,\text{block-size}-1]\)
在文件 Kernel.cpp 第 690 行定义.
Computes row-wise/col-wise sum from a symmetric part of the kernel matrix that always is supposed to contain the main upper diagonal. This method is useful while computing statistical estimation of mean/variance over kernel values but the kernel matrix is too huge to be fit inside memory.
- 参数
-
block_begin | the row and col index at which the block starts |
block_size | the number of rows and cols in the block |
For Example, block_begin 4 and block_size 5 represents the block that starts at index (4,4) in the kernel matrix and goes upto (4+5-1,4+5-1) i.e. (8,8) both inclusive
- 参数
-
no_diag | if true (default), the diagonal elements are excluded from the row/col-wise sum |
- 返回
- vector containing row-wise sum computed as
\[ v[i]=\sum_{j}k(i+\text{block-begin}, j+\text{block-begin}) \]
where \(i,j\in[0,\text{block-size}-1]\)
在文件 Kernel.cpp 第 636 行定义.
Computes sum of kernel values from a specified block. This method is useful while computing statistical estimation of mean/variance over kernel values but the kernel matrix is too huge to be fit inside memory.
- 参数
-
block_begin_row | the row index at which the block starts |
block_begin_col | the col index at which the block starts |
block_size_row | the number of rows in the block |
block_size_col | the number of cols in the block |
For example, block_begin_row 0, block_begin_col 4 and block_size_row 5, block_size_col 6 represents the block that starts at index (0,4) in the kernel matrix and goes upto (0+5-1,4+6-1) i.e. (4,9) both inclusive
- 参数
-
no_diag | if true (default is false), the diagonal elements are excluded from the sum, provided that block_size_row and block_size_col are same (i.e. the block is square). Otherwise, these are always added |
- 返回
- sum of kernel values within the block computed as
\[ \sum_{i}\sum_{j}k(i+\text{block-begin-row}, j+\text{block-begin-col}) \]
where \(i\in[0,\text{block-size-row}-1]\) and \(j\in[0,\text{block-size-col}-1]\)
在文件 Kernel.cpp 第 590 行定义.
Computes sum from a symmetric part of the kernel matrix that always is supposed to contain the main upper diagonal. This method is useful while computing statistical estimation of mean/variance over kernel values but the kernel matrix is too huge to be fit inside memory.
- 参数
-
block_begin | the row and col index at which the block starts |
block_size | the number of rows and cols in the block |
For example, block_begin 4 and block_size 5 represents the block that starts at index (4,4) in the kernel matrix and goes upto (4+5-1,4+5-1) i.e. (8,8) both inclusive
- 参数
-
no_diag | if true (default), the diagonal elements are excluded from the sum |
- 返回
- sum of kernel values within the block computed as
\[ \sum_{i}\sum_{j}k(i+\text{block-begin}, j+\text{block-begin}) \]
where \(i,j\in[0,\text{block-size}-1]\)
在文件 Kernel.cpp 第 537 行定义.