SHOGUN  v3.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
TDistributedStochasticNeighborEmbedding.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) 2013 Vladyslav S. Gorbatiuk
00008  * Copyright (C) 2011-2013 Vladyslav S. Gorbatiuk
00009  */
00010 
00011 #include <shogun/converter/TDistributedStochasticNeighborEmbedding.h>
00012 #ifdef HAVE_EIGEN3
00013 #include <shogun/lib/tapkee/tapkee_shogun.hpp>
00014 #include <shogun/features/DenseFeatures.h>
00015 
00016 using namespace shogun;
00017 
00018 CTDistributedStochasticNeighborEmbedding::CTDistributedStochasticNeighborEmbedding() :
00019         CEmbeddingConverter()
00020 {
00021     // Default values
00022     m_perplexity = 30.0;
00023     m_theta = 0.5;
00024     init();
00025 }
00026 
00027 void CTDistributedStochasticNeighborEmbedding::init()
00028 {
00029     SG_ADD(&m_perplexity, "perplexity", "perplexity", MS_NOT_AVAILABLE);
00030     SG_ADD(&m_theta, "theta", "learning rate", MS_NOT_AVAILABLE);
00031 }
00032 
00033 CTDistributedStochasticNeighborEmbedding::~CTDistributedStochasticNeighborEmbedding()
00034 {
00035 }
00036 
00037 const char* CTDistributedStochasticNeighborEmbedding::get_name() const
00038 {
00039     return "TDistributedStochasticNeighborEmbedding";
00040 }
00041 
00042 void CTDistributedStochasticNeighborEmbedding::set_theta(const float64_t theta)
00043 {
00044 
00045     m_theta = theta;
00046 }
00047 
00048 float64_t CTDistributedStochasticNeighborEmbedding::get_theta() const
00049 {
00050     return m_theta;
00051 }
00052 
00053 void CTDistributedStochasticNeighborEmbedding::set_perplexity(const float64_t perplexity)
00054 {
00055     m_perplexity = perplexity;
00056 }
00057 
00058 float64_t CTDistributedStochasticNeighborEmbedding::get_perplexity() const
00059 {
00060     return m_perplexity;
00061 }
00062 
00063 CFeatures* CTDistributedStochasticNeighborEmbedding::apply(CFeatures* features)
00064 {
00065     TAPKEE_PARAMETERS_FOR_SHOGUN parameters;
00066     parameters.sne_theta = m_theta;
00067     parameters.sne_perplexity = m_perplexity;
00068     parameters.features = (CDotFeatures*)features;
00069 
00070     parameters.method = SHOGUN_TDISTRIBUTED_STOCHASTIC_NEIGHBOR_EMBEDDING;
00071     parameters.target_dimension = m_target_dim;
00072     CDenseFeatures<float64_t>* embedding = tapkee_embed(parameters);
00073     return embedding;
00074 }
00075 
00076 #endif /* HAVE_EIGEN */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation