SHOGUN  v3.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Isomap.cpp
Go to the documentation of this file.
00001 /*
00002  * This program is free software; you can redistribute it and/or modify
00003  * it under the terms of the GNU General Public License as published by
00004  * the Free Software Foundation; either version 3 of the License, or
00005  * (at your option) any later version.
00006  *
00007  * Written (W) 2011-2013 Sergey Lisitsyn
00008  * Copyright (C) 2011-2013 Berlin Institute of Technology and Max-Planck-Society
00009  */
00010 
00011 #include <shogun/converter/Isomap.h>
00012 #ifdef HAVE_EIGEN3
00013 #include <shogun/io/SGIO.h>
00014 #include <shogun/lib/Signal.h>
00015 #include <shogun/lib/tapkee/tapkee_shogun.hpp>
00016 
00017 using namespace shogun;
00018 
00019 CIsomap::CIsomap() : CMultidimensionalScaling()
00020 {
00021     m_k = 3;
00022 
00023     init();
00024 }
00025 
00026 void CIsomap::init()
00027 {
00028     SG_ADD(&m_k, "k", "number of neighbors", MS_AVAILABLE);
00029 }
00030 
00031 CIsomap::~CIsomap()
00032 {
00033 }
00034 
00035 void CIsomap::set_k(int32_t k)
00036 {
00037     ASSERT(k>0)
00038     m_k = k;
00039 }
00040 
00041 int32_t CIsomap::get_k() const
00042 {
00043     return m_k;
00044 }
00045 
00046 const char* CIsomap::get_name() const
00047 {
00048     return "Isomap";
00049 }
00050 
00051 CDenseFeatures<float64_t>* CIsomap::embed_distance(CDistance* distance)
00052 {
00053     TAPKEE_PARAMETERS_FOR_SHOGUN parameters;
00054     if (m_landmark)
00055     {
00056         parameters.method = SHOGUN_LANDMARK_ISOMAP;
00057         parameters.landmark_ratio = float64_t(m_landmark_number)/distance->get_num_vec_lhs();
00058     }
00059     else
00060     {
00061         parameters.method = SHOGUN_ISOMAP;
00062     }
00063     parameters.n_neighbors = m_k;
00064     parameters.target_dimension = m_target_dim;
00065     parameters.distance = distance;
00066     CDenseFeatures<float64_t>* embedding = tapkee_embed(parameters);
00067     return embedding;
00068 }
00069 
00070 #endif /* HAVE_EIGEN3 */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation