SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ManifoldSculpting.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) 2013 Vladyslav S. Gorbatiuk
8  * Copyright (C) 2011-2013 Vladyslav S. Gorbatiuk
9  */
10 
12 #ifdef HAVE_EIGEN3
13 #include <shogun/lib/tapkee/tapkee_shogun.hpp>
16 
17 using namespace shogun;
18 
21 {
22  // Default values
23  m_k = 10;
24  m_squishing_rate = 0.8;
25  m_max_iteration = 80;
26  init();
27 }
28 
29 void CManifoldSculpting::init()
30 {
31  SG_ADD(&m_k, "k", "number of neighbors", MS_NOT_AVAILABLE);
32  SG_ADD(&m_squishing_rate, "quishing_rate",
33  "squishing rate",MS_NOT_AVAILABLE);
34  SG_ADD(&m_max_iteration, "max_iteration",
35  "maximum number of algorithm's iterations", MS_NOT_AVAILABLE);
36 }
37 
39 {
40 }
41 
42 const char* CManifoldSculpting::get_name() const
43 {
44  return "ManifoldSculpting";
45 }
46 
47 void CManifoldSculpting::set_k(const int32_t k)
48 {
49  ASSERT(k>0)
50  m_k = k;
51 }
52 
54 {
55  return m_k;
56 }
57 
59 {
60  ASSERT(squishing_rate >= 0 && squishing_rate < 1)
61  m_squishing_rate = squishing_rate;
62 }
63 
65 {
66  return m_squishing_rate;
67 }
68 
69 void CManifoldSculpting::set_max_iteration(const int32_t max_iteration)
70 {
71  ASSERT(max_iteration > 0)
72  m_max_iteration = max_iteration;
73 }
74 
76 {
77  return m_max_iteration;
78 }
79 
81 {
83  SG_REF(feats);
84  CDistance* euclidean_distance =
85  new CEuclideanDistance(feats, feats);
86 
87  TAPKEE_PARAMETERS_FOR_SHOGUN parameters;
88  parameters.n_neighbors = m_k;
89  parameters.squishing_rate = m_squishing_rate;
90  parameters.max_iteration = m_max_iteration;
91  parameters.features = feats;
92  parameters.distance = euclidean_distance;
93 
94  parameters.method = SHOGUN_MANIFOLD_SCULPTING;
95  parameters.target_dimension = m_target_dim;
96  CDenseFeatures<float64_t>* embedding = tapkee_embed(parameters);
97 
98  SG_UNREF(euclidean_distance);
99 
100  return embedding;
101 }
102 
103 #endif /* HAVE_EIGEN */

SHOGUN Machine Learning Toolbox - Documentation