SHOGUN  5.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
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 #include <shogun/lib/tapkee/tapkee_shogun.hpp>
15 
16 using namespace shogun;
17 
20 {
21  // Default values
22  m_k = 10;
23  m_squishing_rate = 0.8;
24  m_max_iteration = 80;
25  init();
26 }
27 
28 void CManifoldSculpting::init()
29 {
30  SG_ADD(&m_k, "k", "number of neighbors", MS_NOT_AVAILABLE);
31  SG_ADD(&m_squishing_rate, "quishing_rate",
32  "squishing rate",MS_NOT_AVAILABLE);
33  SG_ADD(&m_max_iteration, "max_iteration",
34  "maximum number of algorithm's iterations", MS_NOT_AVAILABLE);
35 }
36 
38 {
39 }
40 
41 const char* CManifoldSculpting::get_name() const
42 {
43  return "ManifoldSculpting";
44 }
45 
46 void CManifoldSculpting::set_k(const int32_t k)
47 {
48  ASSERT(k>0)
49  m_k = k;
50 }
51 
53 {
54  return m_k;
55 }
56 
58 {
59  ASSERT(squishing_rate >= 0 && squishing_rate < 1)
60  m_squishing_rate = squishing_rate;
61 }
62 
64 {
65  return m_squishing_rate;
66 }
67 
68 void CManifoldSculpting::set_max_iteration(const int32_t max_iteration)
69 {
70  ASSERT(max_iteration > 0)
71  m_max_iteration = max_iteration;
72 }
73 
75 {
76  return m_max_iteration;
77 }
78 
80 {
82  SG_REF(feats);
83  CDistance* euclidean_distance =
84  new CEuclideanDistance(feats, feats);
85 
86  TAPKEE_PARAMETERS_FOR_SHOGUN parameters;
87  parameters.n_neighbors = m_k;
88  parameters.squishing_rate = m_squishing_rate;
89  parameters.max_iteration = m_max_iteration;
90  parameters.features = feats;
91  parameters.distance = euclidean_distance;
92 
93  parameters.method = SHOGUN_MANIFOLD_SCULPTING;
94  parameters.target_dimension = m_target_dim;
95  CDenseFeatures<float64_t>* embedding = tapkee_embed(parameters);
96 
97  SG_UNREF(euclidean_distance);
98 
99  return embedding;
100 }
101 
Class Distance, a base class for all the distances used in the Shogun toolbox.
Definition: Distance.h:87
class EmbeddingConverter (part of the Efficient Dimensionality Reduction Toolkit) used to construct e...
void set_squishing_rate(const float64_t squishing_rate)
#define SG_REF(x)
Definition: SGObject.h:54
#define ASSERT(x)
Definition: SGIO.h:201
double float64_t
Definition: common.h:50
void set_max_iteration(const int32_t max_iteration)
#define SG_UNREF(x)
Definition: SGObject.h:55
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
The class Features is the base class of all feature objects.
Definition: Features.h:68
void set_k(const int32_t k)
float64_t get_squishing_rate() const
#define SG_ADD(...)
Definition: SGObject.h:84
int32_t get_max_iteration() const
virtual const char * get_name() const
virtual CFeatures * apply(CFeatures *features)
class EuclideanDistance

SHOGUN Machine Learning Toolbox - Documentation