SHOGUN  4.1.0
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
MMDKernelSelectionOpt.cpp
浏览该文件的文档.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Written (W) 2012-2013 Heiko Strathmann
8  */
9 
13 
14 using namespace shogun;
15 
18 {
19  init();
20 }
21 
23  CKernelTwoSampleTest* mmd, float64_t lambda) :
25 {
26  init();
27 
28  /* currently, this method is only developed for the linear time MMD */
29  REQUIRE(dynamic_cast<CLinearTimeMMD*>(mmd), "%s::%s(): Only "
30  "CLinearTimeMMD is currently supported! Provided instance is "
31  "\"%s\"\n", get_name(), get_name(), mmd->get_name());
32 
33  m_lambda=lambda;
34 }
35 
37 {
38 }
39 
41 {
42  /* comnpute mmd on all subkernels using the same data. Note that underlying
43  * kernel was asserted to be a combined one */
46  ((CLinearTimeMMD*)m_estimator)->compute_statistic_and_variance(mmds, vars, true);
47 
48  /* we know that the underlying MMD is linear time version, cast is safe */
49  SGVector<float64_t> measures(mmds.vlen);
50 
51  for (index_t i=0; i<measures.vlen; ++i)
52  measures[i]=mmds[i]/(CMath::sqrt(vars[i])+m_lambda);
53 
54  return measures;
55 }
56 
57 void CMMDKernelSelectionOpt::init()
58 {
59  /* set to a sensible standard value that proved to be useful in
60  * experiments, see NIPS paper */
61  m_lambda=1E-5;
62 }
int32_t index_t
Definition: common.h:62
virtual SGVector< float64_t > compute_measures()
#define REQUIRE(x,...)
Definition: SGIO.h:206
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.
virtual const char * get_name() const
Kernel two sample test base class. Provides an interface for performing a two-sample test using a ker...
index_t vlen
Definition: SGVector.h:494
double float64_t
Definition: common.h:50
virtual const char * get_name() const =0
CKernelTwoSampleTest * m_estimator
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
This class implements the linear time Maximum Mean Statistic as described in [1] for streaming data (...
Definition: LinearTimeMMD.h:66
static float32_t sqrt(float32_t x)
Definition: Math.h:459

SHOGUN 机器学习工具包 - 项目文档