Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
344 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
n = 1000; | ||
noise = 0.0; | ||
t = (3 * pi / 2) * (1 + 2 * rand(n, 1)); | ||
height = 30 * rand(n, 1); | ||
X = [t .* cos(t) height t .* sin(t)] + noise * randn(n, 3); | ||
|
||
sg('set_features','TRAIN',X'); | ||
sg('set_converter','ltsa',10); | ||
embedding = sg('embed',2); | ||
plot(embedding(:,1),embedding(:,2),'@'); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
/* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Written (W) 2012 Sergey Lisitsyn | ||
* Copyright (C) 2012 Sergey Lisitsyn | ||
*/ | ||
|
||
#include <shogun/ui/GUIConverter.h> | ||
#include <shogun/ui/SGInterface.h> | ||
|
||
#include <shogun/lib/config.h> | ||
#include <shogun/io/SGIO.h> | ||
#include <shogun/features/SimpleFeatures.h> | ||
#include <shogun/kernel/GaussianKernel.h> | ||
|
||
#include <shogun/converter/LocallyLinearEmbedding.h> | ||
#include <shogun/converter/HessianLocallyLinearEmbedding.h> | ||
#include <shogun/converter/LocalTangentSpaceAlignment.h> | ||
#include <shogun/converter/NeighborhoodPreservingEmbedding.h> | ||
#include <shogun/converter/LaplacianEigenmaps.h> | ||
#include <shogun/converter/LocalityPreservingProjections.h> | ||
#include <shogun/converter/DiffusionMaps.h> | ||
#include <shogun/converter/LinearLocalTangentSpaceAlignment.h> | ||
#include <shogun/converter/MultidimensionalScaling.h> | ||
#include <shogun/converter/Isomap.h> | ||
#include <shogun/converter/EmbeddingConverter.h> | ||
|
||
using namespace shogun; | ||
|
||
CGUIConverter::CGUIConverter(CSGInterface* ui) | ||
: CSGObject(), m_ui(ui) | ||
{ | ||
m_converter = NULL; | ||
} | ||
|
||
CGUIConverter::~CGUIConverter() | ||
{ | ||
SG_UNREF(m_converter); | ||
} | ||
|
||
bool CGUIConverter::create_locallylinearembedding(int32_t k) | ||
{ | ||
m_converter = new CLocallyLinearEmbedding(); | ||
((CLocallyLinearEmbedding*)m_converter)->set_k(k); | ||
return true; | ||
} | ||
|
||
bool CGUIConverter::create_neighborhoodpreservingembedding(int32_t k) | ||
{ | ||
m_converter = new CNeighborhoodPreservingEmbedding(); | ||
((CNeighborhoodPreservingEmbedding*)m_converter)->set_k(k); | ||
return true; | ||
} | ||
|
||
bool CGUIConverter::create_localtangentspacealignment(int32_t k) | ||
{ | ||
m_converter = new CLocalTangentSpaceAlignment(); | ||
((CLocalTangentSpaceAlignment*)m_converter)->set_k(k); | ||
return true; | ||
} | ||
|
||
bool CGUIConverter::create_linearlocaltangentspacealignment(int32_t k) | ||
{ | ||
m_converter = new CLinearLocalTangentSpaceAlignment(); | ||
((CLinearLocalTangentSpaceAlignment*)m_converter)->set_k(k); | ||
return true; | ||
} | ||
|
||
bool CGUIConverter::create_hessianlocallylinearembedding(int32_t k) | ||
{ | ||
m_converter = new CLocallyLinearEmbedding(); | ||
((CHessianLocallyLinearEmbedding*)m_converter)->set_k(k); | ||
return true; | ||
} | ||
|
||
bool CGUIConverter::create_laplacianeigenmaps(int32_t k, float64_t width) | ||
{ | ||
m_converter = new CLaplacianEigenmaps(); | ||
((CLaplacianEigenmaps*)m_converter)->set_k(k); | ||
((CLaplacianEigenmaps*)m_converter)->set_tau(width); | ||
return true; | ||
} | ||
|
||
bool CGUIConverter::create_localitypreservingprojections(int32_t k, float64_t width) | ||
{ | ||
m_converter = new CLocalityPreservingProjections(); | ||
((CLocalityPreservingProjections*)m_converter)->set_k(k); | ||
((CLocalityPreservingProjections*)m_converter)->set_tau(width); | ||
return true; | ||
} | ||
|
||
bool CGUIConverter::create_diffusionmaps(int32_t t, float64_t width) | ||
{ | ||
m_converter = new CDiffusionMaps(); | ||
((CDiffusionMaps*)m_converter)->set_t(t); | ||
((CDiffusionMaps*)m_converter)->set_kernel(new CGaussianKernel(100,width)); | ||
return true; | ||
} | ||
|
||
bool CGUIConverter::create_isomap(int32_t k) | ||
{ | ||
m_converter = new CIsomap(); | ||
((CIsomap*)m_converter)->set_k(k); | ||
return true; | ||
} | ||
|
||
bool CGUIConverter::create_multidimensionalscaling() | ||
{ | ||
m_converter = new CMultidimensionalScaling(); | ||
return true; | ||
} | ||
|
||
CSimpleFeatures<float64_t>* CGUIConverter::embed(int32_t target_dim) | ||
{ | ||
if (!m_converter) | ||
SG_ERROR("No converter created"); | ||
((CEmbeddingConverter*)m_converter)->set_target_dim(target_dim); | ||
return ((CEmbeddingConverter*)m_converter)->embed(m_ui->ui_features->get_train_features()); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Written (W) 2012 Sergey Lisitsyn | ||
* Copyright (C) 2012 Sergey Lisitsyn | ||
*/ | ||
|
||
#ifndef __GUICONVERTER_H__ | ||
#define __GUICONVERTER_H__ | ||
|
||
#include <shogun/lib/config.h> | ||
#include <shogun/base/SGObject.h> | ||
#include <shogun/converter/Converter.h> | ||
#include <shogun/features/SimpleFeatures.h> | ||
|
||
namespace shogun | ||
{ | ||
class CSGInterface; | ||
|
||
/** @brief UI converter */ | ||
class CGUIConverter : public CSGObject | ||
{ | ||
public: | ||
/** constructor */ | ||
CGUIConverter() | ||
{ | ||
|
||
}; | ||
|
||
/** constructor | ||
* @param interface | ||
*/ | ||
CGUIConverter(CSGInterface* interface); | ||
|
||
/** create LLE */ | ||
bool create_locallylinearembedding(int32_t k); | ||
/** create NPE */ | ||
bool create_neighborhoodpreservingembedding(int32_t k); | ||
/** create LTSA */ | ||
bool create_localtangentspacealignment(int32_t k); | ||
/** create LLTSA */ | ||
bool create_linearlocaltangentspacealignment(int32_t k); | ||
/** create HLLE */ | ||
bool create_hessianlocallylinearembedding(int32_t k); | ||
/** create Laplacian Eigenmaps */ | ||
bool create_laplacianeigenmaps(int32_t k, float64_t width); | ||
/** create LPP */ | ||
bool create_localitypreservingprojections(int32_t k, float64_t width); | ||
/** create Diffusion maps */ | ||
bool create_diffusionmaps(int32_t t, float64_t width); | ||
/** create Isomap */ | ||
bool create_isomap(int32_t k); | ||
/** create Multidimensional scaling */ | ||
bool create_multidimensionalscaling(); | ||
|
||
/** embed */ | ||
CSimpleFeatures<float64_t>* embed(int32_t target_dim); | ||
|
||
/** destructor */ | ||
~CGUIConverter(); | ||
|
||
/** @return object name */ | ||
virtual const char* get_name() const { return "GUIPreprocessor"; } | ||
|
||
protected: | ||
|
||
/** converter */ | ||
CConverter* m_converter; | ||
|
||
/** ui */ | ||
CSGInterface* m_ui; | ||
}; | ||
} | ||
#endif |
Oops, something went wrong.