SHOGUN  6.1.3
MultiKernelQuadraticTimeMMD.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) The Shogun Machine Learning Toolbox
3  * Written (w) 2012 - 2013 Heiko Strathmann
4  * Written (w) 2014 - 2017 Soumyajit De
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright notice, this
11  * list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright notice,
13  * this list of conditions and the following disclaimer in the documentation
14  * and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
20  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  *
27  * The views and conclusions contained in the software and documentation are those
28  * of the authors and should not be interpreted as representing official policies,
29  * either expressed or implied, of the Shogun Development Team.
30  */
31 
32 #ifndef MULTI_KERNEL_QUADRATIC_TIME_MMD_H_
33 #define MULTI_KERNEL_QUADRATIC_TIME_MMD_H_
34 
35 #include <memory>
36 #include <shogun/base/SGObject.h>
37 
38 namespace shogun
39 {
40 
41 class CFeatures;
42 class CQuadraticTimeMMD;
43 class CShiftInvariantKernel;
44 template <typename> class SGVector;
45 
46 namespace internal
47 {
48 class KernelManager;
49 class MaxMeasure;
50 class MaxTestPower;
51 }
52 
66 {
67  friend class CQuadraticTimeMMD;
68  friend class internal::MaxMeasure;
69  friend class internal::MaxTestPower;
70 private:
72 public:
78 
81 
90  void add_kernel(CShiftInvariantKernel *kernel);
91 
96  void cleanup();
97 
104  SGVector<float64_t> compute_statistic();
105 
113  SGVector<float64_t> compute_variance_h0();
114 
122  SGVector<float64_t> compute_variance_h1();
123 
131  SGVector<float64_t> compute_test_power();
132 
133  /*
134  * Method that computes the null-samples for all the kernels, one column per kernel.
135  * This method uses permutation as the null-approximation technique.
136  *
137  * @return Null-samples for all the kernels.
138  */
139  SGMatrix<float32_t> sample_null();
140 
149  SGVector<float64_t> compute_p_value();
150 
160  SGVector<bool> perform_test(float64_t alpha);
161 
163  virtual const char* get_name() const;
164 private:
165  struct Self;
166  std::unique_ptr<Self> self;
167  void invalidate_precomputed_distance();
168  SGVector<float64_t> statistic(const internal::KernelManager& kernel_mgr);
169  SGVector<float64_t> variance_h1(const internal::KernelManager& kernel_mgr);
170  SGVector<float64_t> test_power(const internal::KernelManager& kernel_mgr);
171  SGMatrix<float32_t> sample_null(const internal::KernelManager& kernel_mgr);
172  SGVector<float64_t> p_values(const internal::KernelManager& kernel_mgr);
173 };
174 
175 }
176 #endif // MULTI_KERNEL_QUADRATIC_TIME_MMD_H_
Base class for the family of kernel functions that only depend on the difference of the inputs...
This class implements the quadratic time Maximum Mean Statistic as described in [1]. The MMD is the distance of two probability distributions and in a RKHS which we denote by .
Class SGObject is the base class of all shogun objects.
Definition: SGObject.h:124
double float64_t
Definition: common.h:60
Class that performs quadratic time MMD test optimized for multiple shift-invariant kernels...
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18

SHOGUN Machine Learning Toolbox - Documentation