25 int32_t size,
bool us)
55 CCommWordStringKernel::init(l,r);
91 for (int32_t i=0; i<
degree; i++)
97 int32_t idx_a, int32_t idx_b,
bool do_sort)
100 bool free_avec, free_bvec;
115 avec=SG_MALLOC(uint16_t, alen);
116 memcpy(avec, av,
sizeof(uint16_t)*alen);
124 bvec=SG_MALLOC(uint16_t, blen);
125 memcpy(bvec, bv,
sizeof(uint16_t)*blen);
136 SG_ERROR(
"not all preprocessors have been applied to training (%d/%d)"
145 for (int32_t d=0; d<
degree; d++)
147 mask = mask | (1 << (degree-d-1));
154 while (left_idx < alen && right_idx < blen)
156 uint16_t lsym=avec[left_idx] & masked;
157 uint16_t rsym=bvec[right_idx] & masked;
161 int32_t old_left_idx=left_idx;
162 int32_t old_right_idx=right_idx;
164 while (left_idx<alen && (avec[left_idx] & masked) ==lsym)
167 while (right_idx<blen && (bvec[right_idx] & masked) ==lsym)
170 result+=weight*(left_idx-old_left_idx)*(right_idx-old_right_idx);
201 for (int32_t j=0; j<len; j++)
205 for (int32_t d=0; d<
degree; d++)
207 mask = mask | (1 << (degree-d-1));
228 int32_t dic_size=1<<(
sizeof(uint16_t)*8);
230 memset(dic, 0,
sizeof(
float64_t)*dic_size);
232 for (uint32_t sym=0; sym<num_symbols; sym++)
237 for (int32_t d=0; d<
degree; d++)
239 mask = mask | (1 << (degree-d-1));
256 SG_ERROR(
"CCommWordStringKernel optimization not initialized\n")
268 for (int32_t j=0; j<len; j++)
272 for (int32_t d=0; d<
degree; d++)
274 mask = mask | (1 << (degree-d-1));
289 int32_t max_degree, int32_t& num_feat, int32_t& num_sym,
float64_t* target,
290 int32_t num_suppvec, int32_t* IDX,
float64_t* alphas,
bool do_init)
295 int32_t dic_size=1<<(
sizeof(uint16_t)*9);
301 num_sym, target, num_suppvec, IDX, alphas,
false);
310 void CWeightedCommWordStringKernel::init()
318 "weights for each of the subkernels of degree 1...d");
virtual bool init(CFeatures *l, CFeatures *r)
SGVector< ST > get_feature_vector(int32_t num)
virtual bool init_optimization(int32_t count, int32_t *IDX, float64_t *weights)
ST shift_offset(ST offset, int32_t amount)
virtual bool init_dictionary(int32_t size)
virtual float64_t normalize_rhs(float64_t value, int32_t idx_rhs)=0
void set_is_initialized(bool p_init)
void free_feature_vector(ST *feat_vec, int32_t num, bool dofree)
float64_t * dictionary_weights
bool get_is_initialized()
CWeightedCommWordStringKernel()
int32_t get_num_preprocessors() const
ST get_masked_symbols(ST symbol, uint8_t mask)
floatmax_t get_num_symbols()
virtual void add_to_normal(int32_t idx, float64_t weight)
The CommWordString kernel may be used to compute the spectrum kernel from strings that have been mapp...
bool set_weights(SGVector< float64_t > weights)
virtual bool init_normalizer()
CFeatures * rhs
feature vectors to occur on right hand side
void add_vector(bool **param, index_t *length, const char *name, const char *description="")
all of classes and functions are contained in the shogun namespace
virtual float64_t * compute_scoring(int32_t max_degree, int32_t &num_feat, int32_t &num_sym, float64_t *target, int32_t num_suppvec, int32_t *IDX, float64_t *alphas, bool do_init=true)
int32_t get_num_preprocessed() const
virtual ~CWeightedCommWordStringKernel()
CFeatures * lhs
feature vectors to occur on left hand side
The class Features is the base class of all feature objects.
ST shift_symbol(ST symbol, int32_t amount)
CKernelNormalizer * normalizer
virtual float64_t * compute_scoring(int32_t max_degree, int32_t &num_feat, int32_t &num_sym, float64_t *target, int32_t num_suppvec, int32_t *IDX, float64_t *alphas, bool do_init=true)
virtual float64_t compute_helper(int32_t idx_a, int32_t idx_b, bool do_sort)
static float32_t sqrt(float32_t x)
virtual float64_t normalize_lhs(float64_t value, int32_t idx_lhs)=0
static void radix_sort(T *array, int32_t size)
virtual float64_t compute_optimized(int32_t idx)