31 #define TRIES(X) ((use_poim_tries) ? (poim_tries.X) : (tries.X))
33 #ifndef DOXYGEN_SHOULD_SKIP_THIS
34 template <
class Trie>
struct S_THREAD_PARAM_WDS
50 #endif // DOXYGEN_SHOULD_SKIP_THIS
60 int32_t size, int32_t d, int32_t mm, int32_t mkls)
150 SG_DEBUG(
"deleting CWeightedDegreePositionStringKernel optimization\n")
175 SG_ERROR(
"unknown optimization type\n")
180 int32_t lhs_changed = (
lhs!=l) ;
181 int32_t rhs_changed = (
rhs!=r) ;
185 SG_DEBUG(
"lhs_changed: %i\n", lhs_changed)
186 SG_DEBUG(
"rhs_changed: %i\n", rhs_changed)
194 int32_t *shifts=SG_MALLOC(int32_t,
shift_len);
205 SG_ERROR(
"All strings in WD kernel must have same length (lhs wrong)!\n")
208 SG_ERROR(
"All strings in WD kernel must have same length (rhs wrong)!\n")
229 SG_DEBUG(
"deleting CWeightedDegreePositionStringKernel optimization\n")
248 int32_t p_count, int32_t * IDX,
float64_t * alphas, int32_t tree_num,
259 SG_ERROR(
"CWeightedDegreePositionStringKernel optimization not implemented for mismatch!=0\n")
264 SG_DEBUG(
"deleting CWeightedDegreePositionStringKernel optimization\n")
269 SG_DEBUG(
"initializing CWeightedDegreePositionStringKernel optimization\n")
271 for (int32_t i=0; i<p_count; i++)
275 if ( (i % (p_count/10+1)) == 0)
281 for (int32_t t=tree_num; t<=upto_tree; t++)
298 SG_DEBUG(
"disabling compact trie nodes with FASTBUTMEMHUNGRY\n")
308 SG_ERROR(
"unknown optimization type\n")
319 char* avec, int32_t alen,
char* bvec, int32_t blen)
327 for (int32_t i=0; i<alen; i++)
332 int32_t mismatches=0;
334 for (int32_t j=0; (j<
degree) && (i+j<alen); j++)
336 if (avec[i+j]!=bvec[i+j])
350 for (int32_t i=0; i<alen; i++)
352 for (int32_t k=1; (k<=
shift[i]) && (i+k<alen); k++)
359 int32_t mismatches=0;
360 for (int32_t j=0; (j<
degree) && (i+j+k<alen); j++)
362 if (avec[i+j+k]!=bvec[i+j])
373 for (int32_t j=0; (j<
degree) && (i+j+k<alen); j++)
375 if (avec[i+j]!=bvec[i+j+k])
386 max_shift_vec[k-1] += sumi1 + sumi2 ;
392 result += max_shift_vec[i]/(2*(i+1)) ;
394 SG_FREE(max_shift_vec);
399 char* avec, int32_t alen,
char* bvec, int32_t blen)
407 for (int32_t i=0; i<alen; i++)
413 for (int32_t j=0; (j<
degree) && (i+j<alen); j++)
415 if (avec[i+j]!=bvec[i+j])
425 for (int32_t i=0; i<alen; i++)
427 for (int32_t k=1; (k<=
shift[i]) && (i+k<alen); k++)
434 for (int32_t j=0; (j<
degree) && (i+j+k<alen); j++)
436 if (avec[i+j+k]!=bvec[i+j])
442 for (int32_t j=0; (j<
degree) && (i+j+k<alen); j++)
444 if (avec[i+j]!=bvec[i+j+k])
451 max_shift_vec[k-1] += sumi1 + sumi2 ;
457 result += max_shift_vec[i]/(2*(i+1)) ;
459 SG_FREE(max_shift_vec);
465 char* avec, int32_t alen,
char* bvec, int32_t blen)
473 for (int32_t i=0; i<alen; i++)
478 for (int32_t j=0; (j<
degree) && (i+j<alen); j++)
480 if (avec[i+j]!=bvec[i+j])
490 for (int32_t i=0; i<alen; i++)
492 for (int32_t k=1; (k<=
shift[i]) && (i+k<alen); k++)
499 for (int32_t j=0; (j<
degree) && (i+j+k<alen); j++)
501 if (avec[i+j+k]!=bvec[i+j])
507 for (int32_t j=0; (j<
degree) && (i+j+k<alen); j++)
509 if (avec[i+j]!=bvec[i+j+k])
516 max_shift_vec[k-1] += sumi1 + sumi2 ;
522 result += max_shift_vec[i]/(2*(i+1)) ;
524 SG_FREE(max_shift_vec);
529 char* avec,
float64_t* pos_weights_lhs, int32_t alen,
char* bvec,
530 float64_t* pos_weights_rhs, int32_t blen)
538 for (int32_t i=0; i<alen; i++)
546 for (int32_t j=0; (j<
degree) && (i+j<alen); j++)
548 posweight_lhs += pos_weights_lhs[i+j] ;
549 posweight_rhs += pos_weights_rhs[i+j] ;
551 if (avec[i+j]!=bvec[i+j])
553 sumi +=
weights[j]*(posweight_lhs/(j+1))*(posweight_rhs/(j+1)) ;
561 for (int32_t i=0; i<alen; i++)
563 for (int32_t k=1; (k<=
shift[i]) && (i+k<alen); k++)
572 for (int32_t j=0; (j<
degree) && (i+j+k<alen); j++)
574 posweight_lhs += pos_weights_lhs[i+j+k] ;
575 posweight_rhs += pos_weights_rhs[i+j] ;
576 if (avec[i+j+k]!=bvec[i+j])
578 sumi1 +=
weights[j]*(posweight_lhs/(j+1))*(posweight_rhs/(j+1)) ;
582 posweight_lhs = 0.0 ;
583 posweight_rhs = 0.0 ;
584 for (int32_t j=0; (j<
degree) && (i+j+k<alen); j++)
586 posweight_lhs += pos_weights_lhs[i+j] ;
587 posweight_rhs += pos_weights_rhs[i+j+k] ;
588 if (avec[i+j]!=bvec[i+j+k])
590 sumi2 +=
weights[j]*(posweight_lhs/(j+1))*(posweight_rhs/(j+1)) ;
595 max_shift_vec[k-1] += sumi1 + sumi2 ;
601 result += max_shift_vec[i]/(2*(i+1)) ;
603 SG_FREE(max_shift_vec);
609 int32_t idx_a, int32_t idx_b)
612 bool free_avec, free_bvec;
656 int32_t *vec = SG_MALLOC(int32_t, len);
658 for (int32_t i=0; i<len; i++)
668 for (int32_t i=0; i<len; i++)
677 SG_ERROR(
"unknown optimization type\n")
680 for (int32_t s=max_s; s>=0; s--)
684 if ((s==0) || (i+s>=len))
696 int32_t idx,
float64_t alpha, int32_t tree_num)
707 int32_t *vec=SG_MALLOC(int32_t, len);
715 max_s=
shift[tree_num];
718 SG_ERROR(
"unknown optimization type\n")
727 for (int32_t s=max_s; s>=0; s--)
737 int32_t s=tree_num-i;
738 if ((i+s<len) && (s>=1) && (s<=
shift[i]))
761 int32_t *vec=SG_MALLOC(int32_t, len);
763 for (int32_t i=0; i<len; i++)
768 for (int32_t i=0; i<len; i++)
773 for (int32_t i=0; i<len; i++)
775 for (int32_t s=1; (s<=
shift[i]) && (i+s<len); s++)
800 int32_t *vec=SG_MALLOC(int32_t, len);
802 for (int32_t i=0; i<len; i++)
807 for (int32_t i=0; i<len; i++)
816 for (int32_t i=0; i<len; i++)
817 for (int32_t k=1; (k<=
shift[i]) && (i+k<len); k++)
906 SG_ERROR(
"WD: Dimension mismatch (should be (seq_length | 1) x degree) got (%d x %d)\n", len,
degree)
922 for (int32_t i=0; i<
degree*len; i++)
941 for (int32_t i=0; i<pws.
vlen; i++)
967 for (int32_t i=0; i<len*num; i++)
974 float64_t* pws, int32_t len, int32_t num)
996 for (int32_t i=0; i<len*num; i++)
1085 for (int32_t i=1; i<
degree+1 ; i++)
1088 for (int32_t i=degree+1; i<
seq_length+1 ; i++)
1102 for (int32_t i=1; i<
degree+1 ; i++)
1105 for (int32_t i=degree+1; i<
seq_length+1 ; i++)
1119 for (int32_t i=1; i<
degree+1 ; i++)
1122 for (int32_t i=degree+1; i<
seq_length+1 ; i++)
1136 for (int32_t i=1; i<
degree+1 ; i++)
1139 for (int32_t i=degree+1; i<
seq_length+1 ; i++)
1174 S_THREAD_PARAM_WDS<DNATrie>* params = (S_THREAD_PARAM_WDS<DNATrie>*) p;
1175 int32_t j=params->j;
1179 int32_t
length=params->length;
1181 int32_t* vec=params->vec;
1184 int32_t*
shift=params->shift;
1185 int32_t* vec_idx=params->vec_idx;
1187 for (int32_t i=params->start; i<params->end; i++)
1208 if ((s>=1) && (s<=shift[q]) && (q+s<len))
1212 len, q, q+s, q, weights, (length!=0)),
1213 vec_idx[i])/(2.0*s);
1217 for (int32_t s=1; (s<=shift[j]) && (j+s<len); s++)
1221 len, j+s, j, j+s, weights, (length!=0)),
1222 vec_idx[i])/(2.0*s);
1231 int32_t num_vec, int32_t* vec_idx,
float64_t* result, int32_t num_suppvec,
1239 ASSERT(num_vec<=rhs->get_num_vectors())
1249 int32_t* vec=SG_MALLOC(int32_t, num_threads*num_feat);
1251 if (num_threads < 2)
1254 for (int32_t j=0; j<num_feat; j++)
1261 S_THREAD_PARAM_WDS<DNATrie> params;
1263 params.result=result;
1266 params.tries=&
tries;
1267 params.factor=factor;
1274 params.vec_idx=vec_idx;
1288 pthread_t* threads = SG_MALLOC(pthread_t, num_threads-1);
1289 S_THREAD_PARAM_WDS<DNATrie>* params = SG_MALLOC(S_THREAD_PARAM_WDS<DNATrie>, num_threads);
1290 int32_t step= num_vec/num_threads;
1293 for (t=0; t<num_threads-1; t++)
1295 params[t].vec=&vec[num_feat*t];
1296 params[t].result=result;
1298 params[t].kernel=
this;
1299 params[t].tries=&
tries;
1300 params[t].factor=factor;
1302 params[t].start = t*step;
1303 params[t].end = (t+1)*step;
1306 params[t].shift=
shift;
1307 params[t].vec_idx=vec_idx;
1311 params[t].vec=&vec[num_feat*t];
1312 params[t].result=result;
1314 params[t].kernel=
this;
1315 params[t].tries=&
tries;
1316 params[t].factor=factor;
1318 params[t].start=t*step;
1319 params[t].end=num_vec;
1322 params[t].shift=
shift;
1323 params[t].vec_idx=vec_idx;
1326 for (t=0; t<num_threads-1; t++)
1327 pthread_join(threads[t], NULL);
1344 int32_t max_degree, int32_t& num_feat, int32_t& num_sym,
float64_t* result,
1345 int32_t num_suppvec, int32_t* IDX,
float64_t* alphas)
1360 int32_t* nofsKmers=SG_MALLOC(int32_t, max_degree);
1369 int32_t bigtabSize=0;
1370 for (k=0; k<max_degree; ++k )
1372 nofsKmers[k]=(int32_t)
CMath::pow(num_sym, k+1);
1373 const int32_t tabSize=nofsKmers[k]*num_feat;
1374 bigtabSize+=tabSize;
1376 result=SG_MALLOC(
float64_t, bigtabSize);
1380 for( k = 0; k < max_degree; ++k )
1382 const int32_t tabSize = nofsKmers[k] * num_feat;
1383 C[k] = &result[tabOffs];
1387 for(i = 0; i < tabSize; i++ )
1398 int32_t* x = SG_MALLOC(int32_t,
degree+1 );
1399 int32_t* substrs = SG_MALLOC(int32_t,
degree+1 );
1401 margFactors[0] = 1.0;
1403 for( k=1; k <
degree; ++k ) {
1404 margFactors[k] = 0.25 * margFactors[k-1];
1409 struct TreeParseInfo info;
1410 info.num_sym = num_sym;
1411 info.num_feat = num_feat;
1414 info.nofsKmers = nofsKmers;
1415 info.margFactors = margFactors;
1417 info.substrs = substrs;
1425 for( k = 0; k < max_degree; ++k )
1427 const int32_t nofKmers = nofsKmers[ k ];
1433 for(int32_t p = 0; p < num_feat; ++p )
1437 for(int32_t j = 0; j < degree+1; j++ ) {
1446 const int32_t j = k - 1;
1447 const int32_t nofJmers = (int32_t)
CMath::pow( num_sym, j+1 );
1448 for(int32_t p = 0; p < num_feat; ++p ) {
1449 const int32_t offsetJ = nofJmers * p;
1450 const int32_t offsetJ1 = nofJmers * (p+1);
1451 const int32_t offsetK = nofKmers * p;
1454 for( y = 0; y < nofJmers; ++y ) {
1455 for( sym = 0; sym < num_sym; ++sym ) {
1456 const int32_t y_sym = num_sym*y + sym;
1457 const int32_t sym_y = nofJmers*sym + y;
1458 ASSERT(0<=y_sym && y_sym<nofKmers)
1459 ASSERT(0<=sym_y && sym_y<nofKmers)
1460 C[k][ y_sym + offsetK ] += L[j][ y + offsetJ ];
1461 if( p < num_feat-1 ) {
1462 C[k][ sym_y + offsetK ] += R[j][ y + offsetJ1 ];
1483 num_sym = bigtabSize;
1486 SG_FREE(margFactors);
1490 for( k = 0; k < max_degree; ++k ) {
1500 int32_t &num_feat, int32_t num_suppvec, int32_t* IDX,
float64_t* alphas)
1513 char* result=SG_MALLOC(
char, num_feat);
1519 for (int32_t i=0; i<num_tables; i++)
1523 for (int32_t i=0; i<num_tables; i++)
1525 bool cumulative=
false;
1565 const char* acgt=
"ACGT";
1572 for (int32_t i=0; i<num_elements; i++)
1575 if (sc>max_score || max_idx==-1)
1581 uint64_t endstr=table[num_tables-1]->
get_element(max_idx).string;
1583 SG_INFO(
"max_idx:%d num_el:%d num_feat:%d num_tables:%d max_score:%f\n", max_idx, num_elements, num_feat, num_tables, max_score)
1585 for (int32_t i=0; i<
degree; i++)
1586 result[num_feat-1-i]=acgt[(endstr >> (2*i)) & 3];
1590 for (int32_t i=num_tables-1; i>=0; i--)
1593 result[i]=acgt[table[i]->
get_element(max_idx).string >> (2*(degree-1)) & 3];
1594 max_idx=table[i]->get_element(max_idx).bt;
1608 for (int32_t i=0; i<num_tables; i++)
1617 int32_t max_degree, int32_t& num_feat, int32_t& num_sym,
1634 const int32_t seqLen = num_feat;
1644 offsets = SG_MALLOC(int32_t, max_degree );
1646 for( k = 0; k < max_degree; ++k ) {
1647 offsets[k] = offset;
1648 const int32_t nofsKmers = (int32_t)
CMath::pow( NUM_SYMS, k+1 );
1649 const int32_t tabSize = nofsKmers * seqLen;
1653 const int32_t bigTabSize = offset;
1654 w_result=SG_MALLOC(
float64_t, bigTabSize);
1655 for (i=0; i<bigTabSize; ++i)
1659 subs = SG_MALLOC(
float64_t*, max_degree );
1661 for( k = 0; k < max_degree; ++k ) {
1662 subs[k] = &w_result[ offsets[k] ];
1673 num_sym = bigTabSize;
1680 int32_t max_degree, int32_t& num_feat, int32_t& num_sym,
1681 float64_t* poim_result, int32_t num_suppvec, int32_t* IDX,
1699 const int32_t seqLen = num_feat;
1715 const int32_t debug = ( max_degree < 0 ) ? ( abs(max_degree) % 4 + 1 ) : 0;
1717 max_degree = abs(max_degree) / 4;
1720 printf(
"POIM DEBUGGING: substring only (max order=%d)\n", max_degree );
1724 printf(
"POIM DEBUGGING: superstring only (max order=%d)\n", max_degree );
1728 printf(
"POIM DEBUGGING: left overlap only (max order=%d)\n", max_degree );
1732 printf(
"POIM DEBUGGING: right overlap only (max order=%d)\n", max_degree );
1736 printf(
"POIM DEBUGGING: something is wrong (max order=%d)\n", max_degree );
1746 offsets = SG_MALLOC(int32_t, max_degree );
1748 for( k = 0; k < max_degree; ++k ) {
1749 offsets[k] = offset;
1750 const int32_t nofsKmers = (int32_t)
CMath::pow( NUM_SYMS, k+1 );
1751 const int32_t tabSize = nofsKmers * seqLen;
1755 const int32_t bigTabSize=offset;
1756 poim_result=SG_MALLOC(
float64_t, bigTabSize);
1757 for (i=0; i<bigTabSize; ++i )
1762 for (k=0; k<max_degree; ++k)
1763 subs[k]=&poim_result[offsets[k]];
1772 if( debug==0 || debug==1 ) {
1774 for( k = 1; k < max_degree; ++k ) {
1775 const int32_t nofKmers2 = ( k > 1 ) ? (int32_t)
CMath::pow(NUM_SYMS,k-1) : 0;
1776 const int32_t nofKmers1 = (int32_t)
CMath::pow( NUM_SYMS, k );
1777 const int32_t nofKmers0 = nofKmers1 * NUM_SYMS;
1778 for( i = 0; i < seqLen; ++i ) {
1779 float64_t*
const subs_k2i1 = ( k>1 && i<seqLen-1 ) ? &subs[k-2][(i+1)*nofKmers2] : NULL;
1780 float64_t*
const subs_k1i1 = ( i < seqLen-1 ) ? &subs[k-1][(i+1)*nofKmers1] : NULL;
1781 float64_t*
const subs_k1i0 = & subs[ k-1 ][ i*nofKmers1 ];
1782 float64_t*
const subs_k0i = & subs[ k-0 ][ i*nofKmers0 ];
1784 for( y0 = 0; y0 < nofKmers0; ++y0 ) {
1785 const int32_t y1l = y0 / NUM_SYMS;
1786 const int32_t y1r = y0 % nofKmers1;
1787 const int32_t y2 = y1r / NUM_SYMS;
1788 subs_k0i[ y0 ] += subs_k1i0[ y1l ];
1789 if( i < seqLen-1 ) {
1790 subs_k0i[ y0 ] += subs_k1i1[ y1r ];
1792 subs_k0i[ y0 ] -= subs_k2i1[ y2 ];
1806 num_sym = bigTabSize;
1827 int32_t max_degree,
CSVM* svm)
1831 int32_t* sv_idx=SG_MALLOC(int32_t, num_suppvec);
1834 for (int32_t i=0; i<num_suppvec; i++)
1840 if ((max_degree < 1) || (max_degree > 12))
1843 SG_WARNING(
"max_degree out of range 1..12 (%d). setting to 1.\n", max_degree)
1889 void CWeightedDegreePositionStringKernel::init()
1936 "weights",
"WD Kernel weights.");
1939 "Weights per position.");
1941 "position_weights_lhs",
1942 "Weights per position left hand side.");
1944 "position_weights_rhs",
1945 "Weights per position right hand side.");
1959 "The selected degree. All degrees are used by default (for value -1).",
virtual void load_serializable_post()
virtual bool init(CFeatures *l, CFeatures *r)
virtual int32_t get_max_vector_length()
int32_t get_num_support_vectors()
SGVector< ST > get_feature_vector(int32_t num)
void compute_POIM2(int32_t max_degree, CSVM *svm)
virtual float64_t compute(int32_t idx_a, int32_t idx_b)
void delete_trees(bool p_use_compact_terminal_nodes=true)
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 *weights)
T get_element(int32_t index) const
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)
void add_example_to_single_tree(int32_t idx, float64_t weight, int32_t tree_num)
void POIMs_add_SLR(float64_t *const *const poims, const int32_t K, const int32_t debug)
SGVector< float64_t > get_POIM2()
int32_t get_num_threads() const
Template class Trie implements a suffix trie, i.e. a tree in which all suffixes up to a certain lengt...
void cleanup_POIM2()
cleanup POIM2
void POIMs_extract_W(float64_t *const *const W, const int32_t K)
float64_t compute_with_mismatch(char *avec, int32_t alen, char *bvec, int32_t blen)
virtual ~CWeightedDegreePositionStringKernel()
void traverse(int32_t tree, const int32_t p, struct TreeParseInfo info, const int32_t depth, int32_t *const x, const int32_t k)
Class ShogunException defines an exception which is thrown whenever an error inside of shogun occurs...
float64_t * compute_abs_weights(int32_t &len)
void create_empty_tries()
virtual bool set_normalizer(CKernelNormalizer *normalizer)
EAlphabet get_alphabet() const
bool set_weights(SGMatrix< float64_t > new_weights)
virtual float64_t normalize_rhs(float64_t value, int32_t idx_rhs)=0
float64_t * compute_POIM(int32_t max_degree, int32_t &num_feat, int32_t &num_sym, float64_t *poim_result, int32_t num_suppvec, int32_t *IDX, float64_t *alphas, float64_t *distrib)
int32_t position_weights_rhs_len
void set_is_initialized(bool p_init)
The class Alphabet implements an alphabet and alphabet utility functions.
int32_t get_num_elements() const
virtual void load_serializable_post()
void free_feature_vector(ST *feat_vec, int32_t num, bool dofree)
bool init_block_weights_cubicpoly()
float64_t * position_weights_lhs
virtual bool delete_optimization()
float64_t * weights_buffer
uint8_t remap_to_bin(uint8_t c)
float64_t compute_by_tree_helper(int32_t *vec, int32_t len, int32_t seq_pos, int32_t tree_pos, int32_t weight_pos, float64_t *weights, bool degree_times_position_weights)
bool init_block_weights_linear()
void POIMs_precalc_SLR(const float64_t *const distrib)
bool init_block_weights_sqpoly()
bool get_is_initialized()
void fill_backtracking_table(int32_t pos, DynArray< ConsensusEntry > *prev, DynArray< ConsensusEntry > *cur, bool cumulative, float64_t *weights)
virtual void remove_lhs()
int32_t position_weights_len
bool init_block_weights_from_wd_external()
CWeightedDegreePositionStringKernel()
bool init_block_weights_log()
void prepare_POIM2(SGMatrix< float64_t > distrib)
void set_position_weights(float64_t *p_position_weights)
int32_t m_poim_result_len
virtual bool init_optimization(int32_t p_count, int32_t *IDX, float64_t *alphas)
void set_shifts(SGVector< int32_t > shifts)
float64_t * block_weights
Class SGObject is the base class of all shogun objects.
bool init_block_weights_exp()
void set_use_compact_terminal_nodes(bool p_use_compact_terminal_nodes)
static void clear_cancel()
virtual void add_example_to_tree(int32_t idx, float64_t weight)
Template Dynamic array class that creates an array that can be used like a list or an array...
bool init_block_weights_const()
bool init_block_weights()
float64_t * m_poim_distrib
void create(int32_t len, bool p_use_compact_terminal_nodes=true)
bool delete_position_weights_rhs()
EOptimizationType get_optimization_type()
bool delete_position_weights_lhs()
float64_t compute_without_mismatch_matrix(char *avec, int32_t alen, char *bvec, int32_t blen)
virtual void set_position_weights(SGVector< float64_t > pws)
float64_t get_alpha(int32_t idx)
CAlphabet * get_alphabet()
float64_t * position_weights
int32_t get_support_vector(int32_t idx)
static bool cancel_computations()
virtual bool init_normalizer()
bool have_same_length(int32_t len=-1)
EOptimizationType opt_type
CFeatures * rhs
feature vectors to occur on right hand side
static int64_t nchoosek(int32_t n, int32_t k)
bool set_position_weights_lhs(float64_t *pws, int32_t len, int32_t num)
float64_t * position_weights_rhs
void add_vector(bool **param, index_t *length, const char *name, const char *description="")
CTrie< POIMTrie > poim_tries
char * compute_consensus(int32_t &num_feat, int32_t num_suppvec, int32_t *IDX, float64_t *alphas)
all of classes and functions are contained in the shogun namespace
float64_t * compute_abs_weights(int32_t &len)
virtual bool set_wd_weights()
void add_to_trie(int32_t i, int32_t seq_offset, int32_t *vec, float32_t alpha, float64_t *weights, bool degree_times_position_weights)
CFeatures * lhs
feature vectors to occur on left hand side
The class Features is the base class of all feature objects.
static float64_t log(float64_t v)
virtual void remove_lhs()
static void * compute_batch_helper(void *p)
A generic Support Vector Machine Interface.
bool get_use_compact_terminal_nodes()
CKernelNormalizer * normalizer
bool set_position_weights_rhs(float64_t *pws, int32_t len, int32_t num)
virtual float64_t compute_by_tree(int32_t idx)
The Weighted Degree Position String kernel (Weighted Degree kernel with shifts).
friend class CSqrtDiagKernelNormalizer
float64_t * extract_w(int32_t max_degree, int32_t &num_feat, int32_t &num_sym, float64_t *w_result, int32_t num_suppvec, int32_t *IDX, float64_t *alphas)
virtual float64_t normalize_lhs(float64_t value, int32_t idx_lhs)=0
void add_matrix(bool **param, index_t *length_y, index_t *length_x, const char *name, const char *description="")
Template class StringKernel, is the base class of all String Kernels.
static int32_t pow(bool x, int32_t n)
int32_t position_weights_lhs_len
float64_t compute_without_mismatch(char *avec, int32_t alen, char *bvec, int32_t blen)
float64_t compute_without_mismatch_position_weights(char *avec, float64_t *posweights_lhs, int32_t alen, char *bvec, float64_t *posweights_rhs, int32_t blen)
virtual int32_t get_vector_length(int32_t vec_num)
bool init_block_weights_from_wd()