12 #ifndef _WEIGHTEDDEGREESTRINGKERNEL_H___
13 #define _WEIGHTEDDEGREESTRINGKERNEL_H___
123 return "WeightedDegreeStringKernel";
134 int32_t count, int32_t *IDX,
float64_t* alphas)
150 int32_t count, int32_t *IDX,
float64_t* alphas, int32_t tree_num);
168 SG_ERROR(
"CWeightedDegreeStringKernel optimization not initialized\n")
189 int32_t num_vec, int32_t* vec_idx,
float64_t* target,
190 int32_t num_suppvec, int32_t* IDX,
float64_t* alphas,
249 int32_t idx,
float64_t * subkernel_contrib)
262 SG_ERROR(
"CWeightedDegreeStringKernel optimization not initialized\n")
279 for (int32_t i=0; i<num_weights; i++)
282 for (int32_t i=0; i<num_weights; i++)
285 for (int32_t i=0; i<num_weights; i++)
298 int32_t num_weights2=w.
vlen;
300 if (num_weights!=num_weights2)
301 SG_ERROR(
"number of weights do not match\n")
305 for (int32_t i=0; i<num_weights; i++)
309 for (int32_t i=0; i<num_weights; i++)
320 for (int32_t i=0; i<num_weights; i++)
325 weights[i*mkl_stepsize+j] = weights2[i];
331 for (int32_t i=0; i<num_weights; i++)
336 weights[i*mkl_stepsize+j] = weights2[i];
348 if (normalizer_ && strcmp(normalizer_->
get_name(),
"MultitaskKernelTreeNormalizer")==0) {
416 num_weights = degree*
length ;
546 inline bool set_degree(int32_t deg) { degree=deg;
return true; }
579 SG_ERROR(
"Stepsize must be a positive integer\n")
625 int32_t idx,
float64_t weight, int32_t tree_num);
641 int32_t idx,
float64_t weight, int32_t tree_num);
669 char* avec, int32_t alen,
char* bvec, int32_t blen);
680 char* avec, int32_t alen,
char* bvec, int32_t blen);
691 char* avec, int32_t alen,
char* bvec, int32_t blen);
702 char* bvec, int32_t blen);
virtual const char * get_name() const =0
float64_t * block_weights
float64_t compute_with_mismatch(char *avec, int32_t alen, char *bvec, int32_t blen)
void delete_trees(bool p_use_compact_terminal_nodes=true)
virtual void add_to_normal(int32_t idx, float64_t weight)
void create_empty_tries()
virtual int32_t get_num_subkernels()
virtual EKernelType get_kernel_type()
EWDKernType get_type() const
ENormalizerType get_normalizer_type()
bool get_use_block_computation()
virtual float64_t compute_optimized(int32_t idx)
void add_example_to_single_tree(int32_t idx, float64_t weight, int32_t tree_num)
bool init_block_weights_exp()
bool init_block_weights_log()
float64_t compute_using_block(char *avec, int32_t alen, char *bvec, int32_t blen)
bool set_degree(int32_t deg)
bool set_max_mismatch(int32_t max)
int32_t position_weights_len
virtual bool set_normalizer(CKernelNormalizer *normalizer)
virtual ~CWeightedDegreeStringKernel()
void add_example_to_single_tree_mismatch(int32_t idx, float64_t weight, int32_t tree_num)
void set_is_initialized(bool p_init)
The class Alphabet implements an alphabet and alphabet utility functions.
virtual void remove_lhs()
bool set_position_weights(float64_t *pws, int32_t len)
virtual bool set_normalizer(CKernelNormalizer *normalizer_)
int32_t get_which_degree()
float64_t * get_weights(int32_t &num_weights)
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)
float64_t * weights_buffer
bool get_is_initialized()
static void * compute_batch_helper(void *p)
CWeightedDegreeStringKernel()
virtual const char * get_name() const
bool set_wd_weights_by_type(EWDKernType type)
virtual bool init_optimization(int32_t count, int32_t *IDX, float64_t *alphas)
int32_t get_mkl_stepsize()
float64_t * position_weights
float64_t compute_without_mismatch(char *avec, int32_t alen, char *bvec, int32_t blen)
bool init_block_weights_from_wd()
void unset_property(EKernelProperty p)
void compute_by_tree(int32_t idx, float64_t *LevelContrib)
The Weighted Degree String kernel.
float64_t * get_degree_weights(int32_t &d, int32_t &len)
virtual void set_subkernel_weights(SGVector< float64_t > w)
float64_t compute_without_mismatch_matrix(char *avec, int32_t alen, char *bvec, int32_t blen)
virtual bool init(CFeatures *l, CFeatures *r)
virtual bool delete_optimization()
The class Kernel Normalizer defines a function to post-process kernel values.
bool set_which_degree(int32_t which)
bool init_block_weights_const()
int32_t get_max_mismatch() const
bool delete_position_weights()
virtual void clear_normal()
Base-class for parameterized Kernel Normalizers.
all of classes and functions are contained in the shogun namespace
bool is_tree_initialized()
bool set_mkl_stepsize(int32_t step)
The class Features is the base class of all feature objects.
void add_example_to_tree(int32_t idx, float64_t weight)
bool init_block_weights_sqpoly()
void compute_by_subkernel(int32_t idx, float64_t *subkernel_contrib)
float64_t compute(int32_t idx_a, int32_t idx_b)
bool init_block_weights_from_wd_external()
CKernelNormalizer * normalizer
void set_wd_weights(SGVector< float64_t > new_weights)
Matrix::Scalar max(Matrix m)
float64_t * compute_abs_weights(int32_t &len)
bool init_block_weights_linear()
const float64_t * get_subkernel_weights(int32_t &num_weights)
bool init_block_weights()
Template class StringKernel, is the base class of all String Kernels.
bool set_use_block_computation(bool block)
void add_example_to_tree_mismatch(int32_t idx, float64_t weight)
int32_t get_degree() const
bool set_weights(SGMatrix< float64_t > new_weights)
bool init_block_weights_cubicpoly()
void set_property(EKernelProperty p)
float64_t * get_position_weights(int32_t &len)
Block< Matrix > block(Matrix matrix, index_t row_begin, index_t col_begin, index_t row_size, index_t col_size)