12 #ifndef _CUSTOMKERNEL_H___
13 #define _CUSTOMKERNEL_H___
83 virtual bool dummy_init(int32_t rows, int32_t cols);
123 virtual const char*
get_name()
const {
return "CustomKernel"; }
141 SG_ERROR(
"%s::set_triangle_kernel_matrix_from_triangle not"
142 " possible with subset. Remove first\n",
get_name());
164 SG_ERROR(
"%s::set_triangle_kernel_matrix_from_triangle_generic "
165 "not possible with subset. Remove first\n",
get_name());
169 int64_t len = tri_kernel_matrix.
vlen;
170 int64_t cols = (int64_t) floor(-0.5 +
CMath::sqrt(0.25+2*len));
172 if (cols*(cols+1)/2 != len)
174 SG_ERROR(
"km should be a vector containing a lower triangle matrix, with len=cols*(cols+1)/2 elements\n")
179 SG_DEBUG(
"using custom kernel of size %dx%d\n", cols,cols)
184 for (int64_t i=0; i<len; i++)
187 dummy_init(cols,cols);
219 SG_ERROR(
"%s::set_triangle_kernel_matrix_from_full_generic "
220 "not possible with subset. Remove first\n",
get_name());
223 int32_t rows = full_kernel_matrix.
num_rows;
224 int32_t cols = full_kernel_matrix.
num_cols;
228 SG_DEBUG(
"using custom kernel of size %dx%d\n", cols,cols)
233 for (int64_t row=0; row<rows; row++)
235 for (int64_t col=row; col<cols; col++)
237 int64_t idx=row * cols - row*(row+1)/2 + col;
259 SG_ERROR(
"%s::set_full_kernel_matrix_from_full "
260 "not possible with subset. Remove first\n",
get_name());
282 SG_ERROR(
"%s::set_full_kernel_matrix_from_full "
283 "not possible with subset. Remove first\n",
get_name());
287 int32_t rows=full_kernel_matrix.
num_rows;
288 int32_t cols=full_kernel_matrix.
num_cols;
289 SG_DEBUG(
"using custom kernel of size %dx%d\n", rows,cols)
294 for (int64_t i=0; i<int64_t(rows) * cols; i++)
379 "Not possible with row subset active! If you want to"
380 " create a %s from another one with a subset, use "
381 "get_kernel_matrix() and the SGMatrix constructor!\n",
385 "Not possible with collumn subset active! If you want to"
386 " create a %s from another one with a subset, use "
387 "get_kernel_matrix() and the SGMatrix constructor!\n",
413 if (real_row <= real_col)
425 return kmatrix(real_row, real_col);
virtual EKernelType get_kernel_type()
virtual void add_row_subset(SGVector< index_t > subset)
SGMatrix< float32_t > kmatrix
int32_t num_rhs
number of feature vectors on right hand side
The Custom Kernel allows for custom user provided kernel matrices.
virtual bool has_features()
SGMatrix< float32_t > get_float32_kernel_matrix()
virtual int32_t get_num_vec_lhs()
CSubsetStack * m_col_subset_stack
bool set_triangle_kernel_matrix_from_full_generic(SGMatrix< T > full_kernel_matrix)
virtual int32_t get_num_vec_rhs()
virtual void remove_all_row_subsets()
EFeatureClass
shogun feature class
class to add subset support to another class. A CSubsetStackStack instance should be added and wrappe...
virtual void remove_col_subset()
bool set_triangle_kernel_matrix_from_triangle(SGVector< float64_t > tri_kernel_matrix)
virtual void remove_row_subset()
virtual void add_col_subset(SGVector< index_t > subset)
virtual void row_subset_changed_post()
virtual EFeatureClass get_feature_class()
bool set_full_kernel_matrix_from_full(SGMatrix< float64_t > full_kernel_matrix)
index_t subset_idx_conversion(index_t idx) const
int32_t num_lhs
number of feature vectors on left hand side
virtual bool dummy_init(int32_t rows, int32_t cols)
virtual void remove_all_col_subsets()
virtual const char * get_name() const
EFeatureType
shogun feature type
all of classes and functions are contained in the shogun namespace
virtual EFeatureType get_feature_type()
bool set_full_kernel_matrix_from_full(SGMatrix< float32_t > full_kernel_matrix)
The class Features is the base class of all feature objects.
virtual void col_subset_changed_post()
virtual bool has_subsets() const
bool set_triangle_kernel_matrix_from_full(SGMatrix< float64_t > full_kernel_matrix)
bool set_triangle_kernel_matrix_from_triangle_generic(SGVector< T > tri_kernel_matrix)
static float32_t sqrt(float32_t x)
x^0.5
virtual float64_t compute(int32_t row, int32_t col)
CSubsetStack * m_row_subset_stack