84 SG_DEBUG(
"created OligoStringKernel (%p) with size %d, k %d, width %f.\n", kern, size, k, width)
93 SG_ERROR(
"Couldn't create DiagKernel with size %d, diag %f.\n", size, diag)
95 SG_DEBUG(
"created DiagKernel (%p) with size %d, diag %f.\n", kern, size, diag)
104 SG_ERROR(
"Couldn't create ConstKernel with c %f.\n", c)
106 SG_DEBUG(
"created ConstKernel (%p) with c %f.\n", kern, c)
116 SG_DEBUG(
"created CustomKernel (%p).\n", kern)
120 if (source_is_diag && dest_is_diag && num_feat==1)
125 else if (!source_is_diag && dest_is_diag && num_vec==num_feat)
135 int32_t size,
float64_t width, int32_t max_shift, int32_t shift_step)
139 SG_ERROR(
"Couldn't create GaussianShiftKernel with size %d, width %f, max_shift %d, shift_step %d.\n", size, width, max_shift, shift_step)
141 SG_DEBUG(
"created GaussianShiftKernel (%p) with size %d, width %f, max_shift %d, shift_step %d.\n", kern, size, width, max_shift, shift_step)
150 SG_ERROR(
"Couldn't create GaussianKernel with size %d, width %f.\n", size, width)
152 SG_DEBUG(
"created GaussianKernel (%p) with size %d, width %f.\n", kern, size, width)
161 SG_ERROR(
"Couldn't create GaussianKernel with size %d, width %f.\n", size, width)
163 SG_DEBUG(
"created GaussianKernel (%p) with size %d, width %f.\n", kern, size, width)
173 SG_ERROR(
"Couldn't create SigmoidKernel with size %d, gamma %f, coef0 %f.\n", size, gamma, coef0)
175 SG_DEBUG(
"created SigmoidKernel (%p) with size %d, gamma %f, coef0 %f.\n", kern, size, gamma, coef0)
184 SG_ERROR(
"Couldn't create WaveletKernel with size %d, Wdilation %f, Wtranslation %f.\n", size, Wdilation, Wtranslation)
186 SG_DEBUG(
"created WaveletKernel (%p) with size %d, Wdilation %f, Wtranslation %f.\n", kern, size, Wdilation, Wtranslation)
191 int32_t size, int32_t degree,
bool inhomogene,
bool normalize)
196 SG_DEBUG(
"created PolyKernel with size %d, degree %d, inhomogene %d normalize %d.\n", kern, size, degree, inhomogene, normalize)
202 int32_t size, int32_t degree,
bool inhomogene,
bool normalize)
207 SG_DEBUG(
"created PolyKernel (%p) with size %d, degree %d, inhomogene %d, normalize %d.\n", kern, size, degree, inhomogene, normalize)
213 int32_t size, int32_t length, int32_t inner_degree, int32_t outer_degree,
221 size, length, inner_degree, outer_degree);
226 size, length, inner_degree, outer_degree);
230 SG_ERROR(
"Couldn't create (Simple)LocalityImprovedStringKernel with size %d, length %d, inner_degree %d, outer_degree %d.\n", size, length, inner_degree, outer_degree)
232 SG_DEBUG(
"created (Simple)LocalityImprovedStringKernel with size %d, length %d, inner_degree %d, outer_degree %d.\n", kern, size, length, inner_degree, outer_degree)
238 int32_t size, int32_t order, int32_t max_mismatch,
bool use_normalization,
239 int32_t mkl_stepsize,
bool block_computation, int32_t single_degree)
241 float64_t* weights=get_weights(order, max_mismatch);
244 if (single_degree>=0)
246 ASSERT(single_degree<order)
247 for (i=0; i<order; i++)
249 if (i!=single_degree)
258 SG_DEBUG(
"created WeightedDegreeStringKernel (%p) with size %d, order %d, "
259 "max_mismatch %d, use_normalization %d, mkl_stepsize %d, "
260 "block_computation %d, single_degree %d.\n",
261 kern, size, order, max_mismatch, (
int) use_normalization, mkl_stepsize,
262 block_computation, single_degree);
264 if (!use_normalization)
268 set_use_block_computation(block_computation);
277 int32_t size, int32_t order, int32_t max_mismatch, int32_t length,
281 int32_t* shifts=SG_MALLOC(int32_t, length);
283 for (i=center; i<length; i++)
284 shifts[i]=(int32_t) floor(((
float64_t) (i-center))/step);
286 for (i=center-1; i>=0; i--)
287 shifts[i]=(int32_t) floor(((
float64_t) (center-i))/step);
289 for (i=0; i<length; i++)
291 if (shifts[i]>length)
295 for (i=0; i<length; i++)
296 SG_INFO(
"shift[%i]=%i\n", i, shifts[i])
298 float64_t* weights=get_weights(order, max_mismatch);
302 SG_ERROR(
"Couldn't create WeightedDegreePositionStringKernel with size %d, order %d, max_mismatch %d, length %d, center %d, step %f.\n", size, order, max_mismatch, length, center, step)
304 SG_DEBUG(
"created WeightedDegreePositionStringKernel with size %d, order %d, max_mismatch %d, length %d, center %d, step %f.\n", kern, size, order, max_mismatch, length, center, step)
310 int32_t size, int32_t order, int32_t max_mismatch, int32_t* shifts,
311 int32_t length, int32_t mkl_stepsize,
float64_t* position_weights)
313 float64_t* weights=get_weights(order, max_mismatch);
318 SG_DEBUG(
"created WeightedDegreePositionStringKernel (%p) with size %d, order %d, max_mismatch %d, length %d and position_weights (MKL stepsize: %d).\n", kern, size, order, max_mismatch, length, mkl_stepsize)
320 if (!position_weights)
322 position_weights=SG_MALLOC(
float64_t, length);
323 for (int32_t i=0; i<length; i++)
324 position_weights[i]=1.0/length;
333 int32_t size, int32_t order, int32_t max_mismatch, int32_t* shifts,
334 int32_t length,
bool use_normalization)
336 float64_t* weights=get_weights(order, max_mismatch);
339 if (!use_normalization)
343 SG_DEBUG(
"created WeightedDegreePositionStringKernel (%p) with size %d, order %d, max_mismatch %d, length %d, use_normalization %d.\n", kern, size, order, max_mismatch, length, use_normalization)
348 float64_t* CGUIKernel::get_weights(int32_t order, int32_t max_mismatch)
354 for (i=0; i<order; i++)
359 for (i=0; i<order; i++)
362 for (i=0; i<order; i++)
364 for (int32_t j=1; j<=max_mismatch; j++)
369 weights[i+j*order]=weights[i]/(nk*
CMath::pow(3, j));
372 weights[i+j*order]=0;
383 SG_ERROR(
"Couldn't create WeightedDegreeRBFKernel with size %d, width %f, degree %d, nof_properties %d.\n", size, width, degree, nof_properties)
385 SG_DEBUG(
"created WeightedDegreeRBFKernel (%p) with size %d, width %f, degree %d, nof_properties %d.\n", kern, size, width, degree, nof_properties)
395 SG_ERROR(
"Couldn't create SpectrumMismatchRBFKernel with size %d, width %f, degree %d, max_mismatch %d.\n", size, width, degree, max_mismatch)
397 SG_DEBUG(
"created SpectrumMismatchRBFKernel (%p) with size %d, width %f, degree %d, max_mismatch %d.\n", kern, size, width, degree, max_mismatch)
408 SG_ERROR(
"Couldn't create LocalAlignmentStringKernel with size %d.\n", size)
410 SG_DEBUG(
"created LocalAlignmentStringKernel (%p) with size %d.\n", kern, size)
419 SG_ERROR(
"Couldn't create FixedDegreeStringKernel with size %d and d %d.\n", size, d)
421 SG_DEBUG(
"created FixedDegreeStringKernel (%p) with size %d and d %d.\n", kern, size, d)
430 SG_ERROR(
"Couldn't create Chi2Kernel with size %d and width %f.\n", size, width)
432 SG_DEBUG(
"created Chi2Kernel (%p) with size %d and width %f.\n", kern, size, width)
438 int32_t size,
bool use_sign,
char* norm_str,
EKernelType ktype)
443 norm_str= (
char*)
"FULL";
452 SG_DEBUG(
"created WeightedCommWord/CommWord/CommUlongStringKernel (%p) with size %d, use_sign %d norm_str %s.\n", kern, size, use_sign, norm_str)
455 if (strncmp(norm_str,
"NO", 2)==0)
459 else if (strncmp(norm_str,
"FULL", 4)==0)
464 SG_ERROR(
"Unsupported Normalizer requested, supports only FULL and NO\n")
470 int32_t size, int32_t d,
bool normalize)
473 SG_DEBUG(
"created MatchWordStringKernel (%p) with size %d and d %d.\n", kern, size, d)
481 int32_t size, int32_t degree,
bool inhomogene,
bool normalize)
484 SG_DEBUG(
"created PolyMatchStringKernel (%p) with size %d, degree %d, inhomogene %d normalize %d.\n", kern, size, degree, inhomogene, normalize)
492 int32_t size, int32_t degree,
bool inhomogene,
bool normalize)
495 SG_DEBUG(
"created PolyMatchWordStringKernel (%p) with size %d, degree %d, inhomogene %d, normalize %d.\n", kern, size, degree, inhomogene, normalize)
504 SG_INFO(
"Getting estimator.\n")
511 SG_ERROR(
"Couldn't create SalzbergWordString with size %d.\n", size)
513 SG_DEBUG(
"created SalzbergWordString (%p) with size %d.\n", kern, size)
532 SG_INFO(
"Getting estimator.\n")
539 SG_ERROR(
"Couldn't create HistogramWordString with size %d.\n", size)
541 SG_DEBUG(
"created HistogramWordString (%p) with size %d.\n", kern, size)
551 SG_DEBUG(
"created LinearByteKernel (%p) with size %d and scale %f.\n", kern, size, scale)
561 SG_DEBUG(
"created LinearWordKernel (%p) with size %d and scale %f.\n", kern, size, scale)
573 SG_DEBUG(
"created LinearStringKernel (%p) with size %d and scale %f.\n", kern, size, scale)
584 SG_DEBUG(
"created LinearKernel (%p) with size %d and scale %f.\n", kern, size, scale)
595 SG_DEBUG(
"created LinearKernel (%p) with size %d and scale %f.\n", kern, size, scale)
607 SG_DEBUG(
"created TPPK (%p) with size %d and km %p, rows %d, cols %d.\n", kern, size, km, rows, cols)
616 SG_ERROR(
"No distance set for DistanceKernel.\n")
620 SG_ERROR(
"Couldn't create DistanceKernel with size %d and width %f.\n", size, width)
622 SG_DEBUG(
"created DistanceKernel (%p) with size %d and width %f.\n", kern, size, width)
628 int32_t size,
bool append_subkernel_weights)
632 SG_ERROR(
"Couldn't create CombinedKernel with size %d and append_subkernel_weights %d.\n", size, append_subkernel_weights)
634 SG_DEBUG(
"created CombinedKernel (%p) with size %d and append_subkernel_weights %d.\n", kern, size, append_subkernel_weights)
649 if (strncmp(normalization,
"IDENTITY", 8)==0)
651 SG_INFO(
"Identity Normalization (==NO NORMALIZATION) selected\n")
654 else if (strncmp(normalization,
"AVGDIAG", 7)==0)
656 SG_INFO(
"Average Kernel Diagonal Normalization selected\n")
659 else if (strncmp(normalization,
"RIDGE", 5)==0)
661 SG_INFO(
"Ridge Kernel Normalization selected\n")
664 else if (strncmp(normalization,
"SQRTDIAG", 8)==0)
666 SG_INFO(
"Sqrt Diagonal Normalization selected\n")
669 else if (strncmp(normalization,
"FIRSTELEMENT", 12)==0)
671 SG_INFO(
"First Element Normalization selected\n")
674 else if (strncmp(normalization,
"VARIANCE", 8)==0)
676 SG_INFO(
"Variance Normalization selected\n")
679 else if (strncmp(normalization,
"SCATTER", 7)==0)
681 SG_INFO(
"Scatter Normalization selected\n")
682 CLabels* train_labels=
ui->ui_labels->get_train_labels();
686 else if (strncmp(normalization,
"ZEROMEANCENTER", 13)==0)
688 SG_INFO(
"Zero Mean Center Normalization selected\n")
692 SG_ERROR(
"Wrong kernel normalizer name.\n")
707 SG_DEBUG(
"set new kernel (%p).\n", kern)
717 CSVM* svm=(
CSVM*)
ui->ui_classifier->get_classifier();
723 int32_t* sv_idx=SG_MALLOC(int32_t, num_sv);
726 for (int32_t i=0; i<num_sv; i++)
738 SG_ERROR(
"Initialization of kernel optimization failed\n")
772 if (!strncmp(target,
"TRAIN", 5))
774 CFeatures* train=
ui->ui_features->get_train_features();
780 if ((k_fclass==fclass || k_fclass==
C_ANY || fclass==
C_ANY) &&
781 (k_ftype==ftype || k_ftype==
F_ANY || ftype==
F_ANY))
784 SG_INFO(
"Initialising kernel with TRAIN DATA, train: %p\n", train)
789 SG_ERROR(
"Kernel can not process this train feature type: %d %d.\n", fclass, ftype)
792 SG_DEBUG(
"Not initing kernel - no train features assigned.\n")
794 else if (!strncmp(target,
"TEST", 4))
796 CFeatures* train=
ui->ui_features->get_train_features();
797 CFeatures* test=
ui->ui_features->get_test_features();
802 if ((k_fclass==fclass || k_fclass==
C_ANY || fclass==
C_ANY) &&
803 (k_ftype==ftype || k_ftype==
F_ANY || ftype==
F_ANY))
810 if ((k_fclass==tr_fclass || k_fclass==
C_ANY || tr_fclass==
C_ANY) &&
811 (k_ftype==tr_ftype || k_ftype==
F_ANY || tr_ftype==
F_ANY))
813 SG_INFO(
"Initialising kernel with TRAIN DATA, train: %p\n", train)
818 SG_ERROR(
"Kernel can not process this train feature type: %d %d.\n", fclass, ftype)
821 SG_INFO(
"Initialising kernel with TEST DATA, train: %p test %p\n", train, test)
826 SG_ERROR(
"Kernel can not process this test feature type: %d %d.\n", fclass, ftype)
829 SG_DEBUG(
"Not initing kernel - no train and test features assigned.\n")
832 SG_ERROR(
"Unknown target %s.\n", target)
848 SG_ERROR(
"Writing to file %s failed!\n", filename)
852 SG_INFO(
"Successfully written kernel to \"%s\" !\n", filename)
856 SG_ERROR(
"No kernel set / kernel not initialized!\n")
864 SG_ERROR(
"Given kernel to add is invalid.\n")
881 SG_ERROR(
"Combined kernel object could not be created.\n")
891 SG_ERROR(
"Adding of kernel failed.\n")
903 SG_ERROR(
"Need a combined kernel for deleting the last kernel in it.\n")
909 SG_ERROR(
"No kernel available to delete.\n")
930 #endif //USE_SVMLIGHT
938 if (strncmp(opt_type,
"FASTBUTMEMHUNGRY", 16)==0)
940 SG_INFO(
"FAST METHOD selected\n")
946 else if (strncmp(opt_type,
"SLOWBUTMEMEFFICIENT", 19)==0)
948 SG_INFO(
"MEMORY EFFICIENT METHOD selected\n")
955 SG_ERROR(
"Wrong kernel optimization type.\n")
966 SG_ERROR(
"Not a combined kernel.\n")
CKernel * create_spectrummismatchrbf(int32_t size=10, float64_t *AA_matrix=NULL, int32_t nr=128, int32_t nc=128, int32_t max_mismatch=1, int32_t degree=1, float64_t width=1)
CKernel * create_linear(int32_t size=10, float64_t scale=-1)
CKernel * create_weighteddegreepositionstring(int32_t size=10, int32_t order=3, int32_t max_mismatch=1, int32_t length=0, int32_t center=0, float64_t step=1)
virtual bool init(CFeatures *lhs, CFeatures *rhs)
int32_t get_num_support_vectors()
CKernel * create_sparsepoly(int32_t size=10, int32_t degree=2, bool inhomogene=false, bool normalize=true)
bool resize_kernel_cache(int32_t size)
Computes the standard linear kernel on CDotFeatures.
The standard Sigmoid kernel computed on dense real valued features.
Computes the standard polynomial kernel on CDotFeatures.
CKernel * create_histogramword(int32_t size=10)
spectrum mismatch rbf kernel
The Diagonal Kernel returns a constant for the diagonal and zero otherwise.
Class Distance, a base class for all the distances used in the Shogun toolbox.
CKernel * create_commstring(int32_t size=10, bool use_sign=false, char *norm_str=NULL, EKernelType ktype=K_WEIGHTEDCOMMWORDSTRING)
CKernel * create_polymatchwordstring(int32_t size=10, int32_t degree=2, bool inhomogene=false, bool normalize=true)
This class offers access to the Oligo Kernel introduced by Meinicke et al. in 2004.
CKernel * create_sparselinear(int32_t size=10, float64_t scale=-1)
The CommUlongString kernel may be used to compute the spectrum kernel from strings that have been map...
The class Labels models labels, i.e. class assignments of objects.
CKernel * create_fixeddegreestring(int32_t size=10, int32_t d=3)
The Custom Kernel allows for custom user provided kernel matrices.
virtual CSGObject * clone()
CKernel * create_linearstring(int32_t size=10, float64_t scale=-1)
CKernel * create_localityimprovedstring(int32_t size=10, int32_t length=3, int32_t inner_degree=3, int32_t outer_degree=1, EKernelType ktype=K_LOCALITYIMPROVED)
virtual bool set_normalizer(CKernelNormalizer *normalizer)
CKernel * create_linearword(int32_t size=10, float64_t scale=-1)
CKernel * create_weighteddegreepositionstring2(int32_t size=10, int32_t order=3, int32_t max_mismatch=1, int32_t *shifts=NULL, int32_t length=0, bool use_normalization=true)
CKernel * create_gaussianshift(int32_t size=10, float64_t width=1, int32_t max_shift=0, int32_t shift_step=1)
The FixedDegree String kernel takes as input two strings of same size and counts the number of matche...
virtual bool delete_optimization()
void set_cache_size(int32_t size)
bool init_kernel(const char *target)
virtual void set_optimization_type(EOptimizationType t)
The SalzbergWordString kernel implements the Salzberg kernel.
CKernel * create_linearbyte(int32_t size=10, float64_t scale=-1)
CKernel * create_combined(int32_t size=10, bool append_subkernel_weights=false)
CKernel * create_custom(float64_t *kmatrix, int32_t num_feat, int32_t num_vec, bool source_is_diag, bool dest_is_diag)
The WeightedCommWordString kernel may be used to compute the weighted spectrum kernel (i...
Computes the Tensor Product Pair Kernel (TPPK).
EFeatureClass
shogun feature class
bool get_is_initialized()
The Constant Kernel returns a constant for all elements.
The Chi2 kernel operating on realvalued vectors computes the chi-squared distance between sets of his...
bool set_triangle_kernel_matrix_from_triangle(SGVector< float64_t > tri_kernel_matrix)
The class PolyMatchWordStringKernel computes a variant of the polynomial kernel on word-features...
bool has_property(EKernelProperty p)
Class CSVFile used to read data from comma-separated values (CSV) files. See http://en.wikipedia.org/wiki/Comma-separated_values.
bool save_kernel(char *filename)
The HistogramWordString computes the TOP kernel on inhomogeneous Markov Chains.
CKernel * create_localalignmentstring(int32_t size=10)
CKernel * create_salzbergword(int32_t size=10)
bool set_optimization_type(char *opt_type)
CKernel * create_weighteddegreepositionstring3(int32_t size=10, int32_t order=3, int32_t max_mismatch=1, int32_t *shifts=NULL, int32_t length=0, int32_t mkl_stepsize=1, float64_t *position_weights=NULL)
CKernel * create_weighteddegreerbf(int32_t size=10, int32_t degree=1, int32_t nof_properties=1, float64_t width=1)
CKernel * create_const(int32_t size=10, float64_t c=1)
Class SGObject is the base class of all shogun objects.
CKernel * create_weighteddegreestring(int32_t size=10, int32_t order=3, int32_t max_mismatch=1, bool use_normalization=true, int32_t mkl_stepsize=1, bool block_computation=true, int32_t single_degree=-1)
CKernel * create_sigmoid(int32_t size=10, float64_t gamma=0.01, float64_t coef0=0)
Computes the standard linear kernel on dense char valued features.
An experimental kernel inspired by the WeightedDegreePositionStringKernel and the Gaussian kernel...
The CommWordString kernel may be used to compute the spectrum kernel from strings that have been mapp...
virtual EFeatureType get_feature_type()=0
CKernel * create_poly(int32_t size=10, int32_t degree=2, bool inhomogene=false, bool normalize=true)
The class PolyMatchStringKernel computes a variant of the polynomial kernel on strings of same length...
void set_combined_kernel_weight(float64_t nw)
float64_t get_alpha(int32_t idx)
The Weighted Degree String kernel.
bool set_full_kernel_matrix_from_full(SGMatrix< float32_t > full_kernel_matrix, bool check_symmetry=false)
virtual EFeatureClass get_feature_class() const =0
The Combined kernel is used to combine a number of kernels into a single CombinedKernel object by lin...
the scatter kernel normalizer
Normalize the kernel by a constant obtained from the first element of the kernel matrix, i.e. .
Identity Kernel Normalization, i.e. no normalization is applied.
The class MatchWordStringKernel computes a variant of the polynomial kernel on strings of same length...
Normalize the kernel by adding a constant term to its diagonal. This aids kernels to become positive ...
SimpleLocalityImprovedString kernel, is a ``simplified'' and better performing version of the Localit...
CKernel * create_diag(int32_t size=10, float64_t diag=1)
int32_t get_support_vector(int32_t idx)
ZeroMeanCenterKernelNormalizer centers the kernel in feature space.
The well known Gaussian kernel (swiss army knife for SVMs) computed on CDotFeatures.
The Distance kernel takes a distance as input.
CKernel * create_chi2(int32_t size=10, float64_t width=1)
EFeatureType
shogun feature type
bool delete_kernel_optimization()
static int64_t nchoosek(int32_t n, int32_t k)
weighted degree RBF kernel
SqrtDiagKernelNormalizer divides by the Square Root of the product of the diagonal elements...
all of classes and functions are contained in the shogun namespace
CKernel * create_matchwordstring(int32_t size=10, int32_t d=3, bool normalize=true)
Normalize the kernel by either a constant or the average value of the diagonal elements (depending on...
virtual EKernelType get_kernel_type()=0
virtual bool init_optimization(int32_t count, int32_t *IDX, float64_t *weights)
The class Features is the base class of all feature objects.
void scale(Matrix A, Matrix B, typename Matrix::Scalar alpha)
CKernel * create_wavelet(int32_t size=10, float64_t Wdilation=5.0, float64_t Wtranslation=2.0)
A generic Support Vector Machine Interface.
bool set_triangle_kernel_matrix_from_full(SGMatrix< float64_t > full_kernel_matrix)
bool precompute_subkernels()
CKernel * create_gaussian(int32_t size=10, float64_t width=1)
CKernel * create_oligo(int32_t size, int32_t k, float64_t width)
CKernel * create_tppk(int32_t size, float64_t *km, int32_t rows, int32_t cols)
bool init_kernel_optimization()
The Weighted Degree Position String kernel (Weighted Degree kernel with shifts).
bool set_kernel(CKernel *kern)
The LocalAlignmentString kernel compares two sequences through all possible local alignments between ...
CKernel * create_distance(int32_t size=10, float64_t width=1)
CKernel * create_polymatchstring(int32_t size=10, int32_t degree=2, bool inhomogene=false, bool normalize=true)
static int32_t pow(bool x, int32_t n)
VarianceKernelNormalizer divides by the ``variance''.
void resize_kernel_cache(KERNELCACHE_IDX size, bool regression_hack=false)
bool add_kernel(CKernel *kern, float64_t weight=1)
virtual EFeatureType get_feature_type() const =0
The LocalityImprovedString kernel is inspired by the polynomial kernel. Comparing neighboring charact...
virtual EFeatureClass get_feature_class()=0
CKernel * create_sparsegaussian(int32_t size=10, float64_t width=1)
bool set_normalization(char *normalization, float64_t c=0.0, float64_t r=0.0)