19 CMMDKernelSelectionComb::CMMDKernelSelectionComb() :
25 CMMDKernelSelectionComb::CMMDKernelSelectionComb(
31 CMMDKernelSelectionComb::~CMMDKernelSelectionComb()
35 void CMMDKernelSelectionComb::init()
37 SG_ADD(&m_opt_max_iterations,
"opt_max_iterations",
"Maximum number of "
39 SG_ADD(&m_opt_epsilon,
"opt_epsilon",
"Stopping criterion for qp solver",
41 SG_ADD(&m_opt_low_cut,
"opt_low_cut",
"Low cut value for optimization "
45 m_opt_max_iterations=10000;
50 CKernel* CMMDKernelSelectionComb::select_kernel()
66 const float64_t* CMMDKernelSelectionComb::get_Q_col(uint32_t i)
68 return &m_Q[m_Q.num_rows*i];
72 void CMMDKernelSelectionComb::print_state(libqp_state_T state)
74 SG_SDEBUG(
"libqp state: primal=%f\n", state.QP);
105 SG_DEBUG(
"found at least one positive MMD\n")
113 SG_WARNING(
"All mmd estimates are negative. This is techically possible,"
114 "although extremely rare. Consider using different kernels. "
115 "This combination will lead to a bad two-sample test. Since any"
116 "combination is bad, will now just return equally distributed "
125 SG_DEBUG(
"one MMD entry is positive, performing optimisation\n")
127 for (
index_t i=0; i<num_kernels; ++i)
135 weights[i]=1.0/sum_mmds;
139 SG_DEBUG(
"starting libqp optimization\n")
140 libqp_state_T qp_exitflag=libqp_gsmo_solver(&get_Q_col, Q_diag.vector,
141 f.vector, mmds.vector,
143 lb.vector, ub.vector,
144 weights.vector, num_kernels, m_opt_max_iterations,
145 m_opt_epsilon, &(CMMDKernelSelectionComb::print_state));
147 SG_DEBUG("libqp returns: nIts=%d, exit_flag: %d\n", qp_exitflag.nIter,
148 qp_exitflag.exitflag);
152 for (
index_t i=0; i<weights.vlen; ++i)
154 if (weights[i]<m_opt_low_cut)
156 SG_DEBUG(
"lowcut: weight[%i]=%f<%f setting to zero\n", i, weights[i],
161 sum_weights+=weights[i];
166 weights[i]/=sum_weights;
171 #endif //USE_GPL_SHOGUN
virtual void set_subkernel_weights(SGVector< float64_t > weights)
static const float64_t INFTY
infinity
Base class for kernel selection for MMD-based two-sample test statistic implementations. Provides abstract methods for selecting kernels and computing criteria or kernel weights for the implemented method. In order to implement new methods for kernel selection, simply write a new implementation of this class.
Kernel two sample test base class. Provides an interface for performing a two-sample test using a ker...
CKernel * get_kernel(int32_t idx)
The Combined kernel is used to combine a number of kernels into a single CombinedKernel object by lin...
all of classes and functions are contained in the shogun namespace
void set_const(T const_elem)