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())
1251 int32_t num_threads=1;
1254 int32_t* vec=SG_MALLOC(int32_t, num_threads*num_feat);
1256 if (num_threads < 2)
1262 S_THREAD_PARAM_WDS<DNATrie> params;
1264 params.result=result;
1267 params.tries=&
tries;
1268 params.factor=factor;
1275 params.vec_idx=vec_idx;
1289 pthread_t* threads = SG_MALLOC(pthread_t, num_threads-1);
1290 S_THREAD_PARAM_WDS<DNATrie>* params = SG_MALLOC(S_THREAD_PARAM_WDS<DNATrie>, num_threads);
1291 int32_t step= num_vec/num_threads;
1294 for (t=0; t<num_threads-1; t++)
1296 params[t].vec=&vec[num_feat*t];
1297 params[t].result=result;
1299 params[t].kernel=
this;
1300 params[t].tries=&
tries;
1301 params[t].factor=factor;
1303 params[t].start = t*step;
1304 params[t].end = (t+1)*step;
1307 params[t].shift=
shift;
1308 params[t].vec_idx=vec_idx;
1312 params[t].vec=&vec[num_feat*t];
1313 params[t].result=result;
1315 params[t].kernel=
this;
1316 params[t].tries=&
tries;
1317 params[t].factor=factor;
1319 params[t].start=t*step;
1320 params[t].end=num_vec;
1323 params[t].shift=
shift;
1324 params[t].vec_idx=vec_idx;
1327 for (t=0; t<num_threads-1; t++)
1328 pthread_join(threads[t], NULL);
1345 int32_t max_degree, int32_t& num_feat, int32_t& num_sym,
float64_t* result,
1346 int32_t num_suppvec, int32_t* IDX,
float64_t* alphas)
1361 int32_t* nofsKmers=SG_MALLOC(int32_t, max_degree);
1370 int32_t bigtabSize=0;
1371 for (k=0; k<max_degree; ++k )
1373 nofsKmers[k]=(int32_t)
CMath::pow(num_sym, k+1);
1374 const int32_t tabSize=nofsKmers[k]*num_feat;
1375 bigtabSize+=tabSize;
1377 result=SG_MALLOC(
float64_t, bigtabSize);
1381 for( k = 0; k < max_degree; ++k )
1383 const int32_t tabSize = nofsKmers[k] * num_feat;
1384 C[k] = &result[tabOffs];
1388 for(i = 0; i < tabSize; i++ )
1399 int32_t* x = SG_MALLOC(int32_t,
degree+1 );
1400 int32_t* substrs = SG_MALLOC(int32_t,
degree+1 );
1402 margFactors[0] = 1.0;
1404 for( k=1; k <
degree; ++k ) {
1405 margFactors[k] = 0.25 * margFactors[k-1];
1410 struct TreeParseInfo info;
1411 info.num_sym = num_sym;
1412 info.num_feat = num_feat;
1415 info.nofsKmers = nofsKmers;
1416 info.margFactors = margFactors;
1418 info.substrs = substrs;
1426 for( k = 0; k < max_degree; ++k )
1428 const int32_t nofKmers = nofsKmers[ k ];
1434 for(int32_t p = 0; p < num_feat; ++p )
1438 for(int32_t j = 0; j < degree+1; j++ ) {
1447 const int32_t j = k - 1;
1448 const int32_t nofJmers = (int32_t)
CMath::pow( num_sym, j+1 );
1449 for(int32_t p = 0; p < num_feat; ++p ) {
1450 const int32_t offsetJ = nofJmers * p;
1451 const int32_t offsetJ1 = nofJmers * (p+1);
1452 const int32_t offsetK = nofKmers * p;
1455 for( y = 0; y < nofJmers; ++y ) {
1456 for( sym = 0; sym < num_sym; ++sym ) {
1457 const int32_t y_sym = num_sym*y + sym;
1458 const int32_t sym_y = nofJmers*sym + y;
1459 ASSERT(0<=y_sym && y_sym<nofKmers)
1460 ASSERT(0<=sym_y && sym_y<nofKmers)
1461 C[k][ y_sym + offsetK ] += L[j][ y + offsetJ ];
1462 if( p < num_feat-1 ) {
1463 C[k][ sym_y + offsetK ] += R[j][ y + offsetJ1 ];
1484 num_sym = bigtabSize;
1487 SG_FREE(margFactors);
1491 for( k = 0; k < max_degree; ++k ) {
1501 int32_t &num_feat, int32_t num_suppvec, int32_t* IDX,
float64_t* alphas)
1514 char* result=SG_MALLOC(
char, num_feat);
1520 for (int32_t i=0; i<num_tables; i++)
1524 for (int32_t i=0; i<num_tables; i++)
1526 bool cumulative=
false;
1566 const char* acgt=
"ACGT";
1573 for (int32_t i=0; i<num_elements; i++)
1576 if (sc>max_score || max_idx==-1)
1582 uint64_t endstr=table[num_tables-1]->
get_element(max_idx).string;
1584 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)
1586 for (int32_t i=0; i<
degree; i++)
1587 result[num_feat-1-i]=acgt[(endstr >> (2*i)) & 3];
1591 for (int32_t i=num_tables-1; i>=0; i--)
1594 result[i]=acgt[table[i]->
get_element(max_idx).string >> (2*(degree-1)) & 3];
1595 max_idx=table[i]->get_element(max_idx).bt;
1609 for (int32_t i=0; i<num_tables; i++)
1618 int32_t max_degree, int32_t& num_feat, int32_t& num_sym,
1635 const int32_t seqLen = num_feat;
1645 offsets = SG_MALLOC(int32_t, max_degree );
1647 for( k = 0; k < max_degree; ++k ) {
1648 offsets[k] = offset;
1649 const int32_t nofsKmers = (int32_t)
CMath::pow( NUM_SYMS, k+1 );
1650 const int32_t tabSize = nofsKmers * seqLen;
1654 const int32_t bigTabSize = offset;
1655 w_result=SG_MALLOC(
float64_t, bigTabSize);
1656 for (i=0; i<bigTabSize; ++i)
1660 subs = SG_MALLOC(
float64_t*, max_degree );
1662 for( k = 0; k < max_degree; ++k ) {
1663 subs[k] = &w_result[ offsets[k] ];
1674 num_sym = bigTabSize;
1681 int32_t max_degree, int32_t& num_feat, int32_t& num_sym,
1682 float64_t* poim_result, int32_t num_suppvec, int32_t* IDX,
1700 const int32_t seqLen = num_feat;
1716 const int32_t debug = ( max_degree < 0 ) ? ( abs(max_degree) % 4 + 1 ) : 0;
1718 max_degree = abs(max_degree) / 4;
1721 printf(
"POIM DEBUGGING: substring only (max order=%d)\n", max_degree );
1725 printf(
"POIM DEBUGGING: superstring only (max order=%d)\n", max_degree );
1729 printf(
"POIM DEBUGGING: left overlap only (max order=%d)\n", max_degree );
1733 printf(
"POIM DEBUGGING: right overlap only (max order=%d)\n", max_degree );
1737 printf(
"POIM DEBUGGING: something is wrong (max order=%d)\n", max_degree );
1747 offsets = SG_MALLOC(int32_t, max_degree );
1749 for( k = 0; k < max_degree; ++k ) {
1750 offsets[k] = offset;
1751 const int32_t nofsKmers = (int32_t)
CMath::pow( NUM_SYMS, k+1 );
1752 const int32_t tabSize = nofsKmers * seqLen;
1756 const int32_t bigTabSize=offset;
1757 poim_result=SG_MALLOC(
float64_t, bigTabSize);
1758 for (i=0; i<bigTabSize; ++i )
1763 for (k=0; k<max_degree; ++k)
1764 subs[k]=&poim_result[offsets[k]];
1773 if( debug==0 || debug==1 ) {
1775 for( k = 1; k < max_degree; ++k ) {
1776 const int32_t nofKmers2 = ( k > 1 ) ? (int32_t)
CMath::pow(NUM_SYMS,k-1) : 0;
1777 const int32_t nofKmers1 = (int32_t)
CMath::pow( NUM_SYMS, k );
1778 const int32_t nofKmers0 = nofKmers1 * NUM_SYMS;
1779 for( i = 0; i < seqLen; ++i ) {
1780 float64_t*
const subs_k2i1 = ( k>1 && i<seqLen-1 ) ? &subs[k-2][(i+1)*nofKmers2] : NULL;
1781 float64_t*
const subs_k1i1 = ( i < seqLen-1 ) ? &subs[k-1][(i+1)*nofKmers1] : NULL;
1782 float64_t*
const subs_k1i0 = & subs[ k-1 ][ i*nofKmers1 ];
1783 float64_t*
const subs_k0i = & subs[ k-0 ][ i*nofKmers0 ];
1785 for( y0 = 0; y0 < nofKmers0; ++y0 ) {
1786 const int32_t y1l = y0 / NUM_SYMS;
1787 const int32_t y1r = y0 % nofKmers1;
1788 const int32_t y2 = y1r / NUM_SYMS;
1789 subs_k0i[ y0 ] += subs_k1i0[ y1l ];
1790 if( i < seqLen-1 ) {
1791 subs_k0i[ y0 ] += subs_k1i1[ y1r ];
1793 subs_k0i[ y0 ] -= subs_k2i1[ y2 ];
1807 num_sym = bigTabSize;
1828 int32_t max_degree,
CSVM* svm)
1832 int32_t* sv_idx=SG_MALLOC(int32_t, num_suppvec);
1835 for (int32_t i=0; i<num_suppvec; i++)
1841 if ((max_degree < 1) || (max_degree > 12))
1844 SG_WARNING(
"max_degree out of range 1..12 (%d). setting to 1.\n", max_degree)
1890 void CWeightedDegreePositionStringKernel::init()
1937 "weights",
"WD Kernel weights.");
1940 "Weights per position.");
1942 "position_weights_lhs",
1943 "Weights per position left hand side.");
1945 "position_weights_rhs",
1946 "Weights per position right hand side.");
1960 "The selected degree. All degrees are used by default (for value -1).",
virtual void load_serializable_post()
virtual bool init(CFeatures *l, CFeatures *r)
int32_t get_num_support_vectors()
void compute_POIM2(int32_t max_degree, CSVM *svm)
virtual float64_t compute(int32_t idx_a, int32_t idx_b)
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)
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)
float64_t * compute_abs_weights(int32_t &len)
SGVector< float64_t > get_POIM2()
void fill_backtracking_table(int32_t pos, DynArray< ConsensusEntry > *prev, DynArray< ConsensusEntry > *cur, bool cumulative, float64_t *weights)
int32_t get_num_threads() const
int32_t get_num_elements() const
void cleanup_POIM2()
cleanup POIM2
float64_t compute_with_mismatch(char *avec, int32_t alen, char *bvec, int32_t blen)
T get_element(int32_t index) const
virtual ~CWeightedDegreePositionStringKernel()
Class ShogunException defines an exception which is thrown whenever an error inside of shogun occurs...
float64_t * compute_abs_weights(int32_t &len)
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)
void create_empty_tries()
virtual bool set_normalizer(CKernelNormalizer *normalizer)
bool set_weights(SGMatrix< float64_t > new_weights)
virtual float64_t normalize_rhs(float64_t value, int32_t idx_rhs)=0
void set_use_compact_terminal_nodes(bool p_use_compact_terminal_nodes)
Template class Trie implements a suffix trie, i.e. a tree in which all suffixes up to a certain lengt...
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.
virtual void load_serializable_post()
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)
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)
bool init_block_weights_linear()
void create(int32_t len, bool p_use_compact_terminal_nodes=true)
bool init_block_weights_sqpoly()
bool get_is_initialized()
virtual void remove_lhs()
int32_t position_weights_len
void POIMs_extract_W(float64_t *const *const W, const int32_t K)
bool get_use_compact_terminal_nodes()
void traverse(int32_t tree, const int32_t p, struct TreeParseInfo info, const int32_t depth, int32_t *const x, const int32_t k)
bool init_block_weights_from_wd_external()
virtual int32_t get_vector_length(int32_t vec_num)
CWeightedDegreePositionStringKernel()
bool init_block_weights_log()
void prepare_POIM2(SGMatrix< float64_t > distrib)
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 POIMs_precalc_SLR(const float64_t *const distrib)
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 free_feature_vector(ST *feat_vec, int32_t num, bool dofree)
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)
SGVector< ST > get_feature_vector(int32_t num)
float64_t * position_weights
int32_t get_support_vector(int32_t idx)
void delete_trees(bool p_use_compact_terminal_nodes=true)
static bool cancel_computations()
virtual bool init_normalizer()
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
T sum(const Container< T > &a, bool no_diag=false)
virtual bool set_wd_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 int32_t get_max_vector_length()
virtual void remove_lhs()
static void * compute_batch_helper(void *p)
A generic Support Vector Machine Interface.
CKernelNormalizer * normalizer
bool set_position_weights_rhs(float64_t *pws, int32_t len, int32_t num)
CAlphabet * get_alphabet()
virtual float64_t compute_by_tree(int32_t idx)
The Weighted Degree Position String kernel (Weighted Degree kernel with shifts).
friend class CSqrtDiagKernelNormalizer
void POIMs_add_SLR(float64_t *const *const poims, const int32_t K, const int32_t debug)
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 set_position_weights(float64_t *p_position_weights)
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.
bool have_same_length(int32_t len=-1)
static int32_t pow(bool x, int32_t n)
EAlphabet get_alphabet() const
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)
bool init_block_weights_from_wd()