SHOGUN  v3.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MMDKernelSelectionOpt.cpp
Go to the documentation of this file.
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 
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_mmd)->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 }

SHOGUN Machine Learning Toolbox - Documentation