SHOGUN  v3.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
FactorAnalysis.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 Fernando J. Iglesias Garcia
00008  * Copyright (C) 2011-2013 Fernando J. Iglesias Garcia
00009  */
00010 
00011 #include <shogun/converter/FactorAnalysis.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 CFactorAnalysis::CFactorAnalysis() :
00019         CEmbeddingConverter()
00020 {
00021     // Sentinel value, it will be set appropriately if not modified by set_max_iteration
00022     m_max_iteration = 0;
00023     m_epsilon = 1e-5;
00024     init();
00025 }
00026 
00027 void CFactorAnalysis::init()
00028 {
00029     SG_ADD(&m_max_iteration, "max_iteration", "maximum number of iterations", MS_NOT_AVAILABLE);
00030     SG_ADD(&m_epsilon, "epsilon", "convergence parameter", MS_NOT_AVAILABLE);
00031 }
00032 
00033 CFactorAnalysis::~CFactorAnalysis()
00034 {
00035 }
00036 
00037 const char* CFactorAnalysis::get_name() const
00038 {
00039     return "FactorAnalysis";
00040 }
00041 
00042 void CFactorAnalysis::set_max_iteration(const int32_t max_iteration)
00043 {
00044     m_max_iteration = max_iteration;
00045 }
00046 
00047 int32_t CFactorAnalysis::get_max_iteration() const
00048 {
00049     return m_max_iteration;
00050 }
00051 
00052 void CFactorAnalysis::set_epsilon(const float64_t epsilon)
00053 {
00054     m_epsilon = epsilon;
00055 }
00056 
00057 float64_t CFactorAnalysis::get_epsilon() const
00058 {
00059     return m_epsilon;
00060 }
00061 
00062 CFeatures* CFactorAnalysis::apply(CFeatures* features)
00063 {
00064     TAPKEE_PARAMETERS_FOR_SHOGUN parameters;
00065     parameters.max_iteration = m_max_iteration;
00066     parameters.features = (CDotFeatures*)features;
00067     parameters.fa_epsilon = m_epsilon;
00068     parameters.method = SHOGUN_FACTOR_ANALYSIS;
00069     parameters.target_dimension = m_target_dim;
00070     CDenseFeatures<float64_t>* embedding = tapkee_embed(parameters);
00071     return embedding;
00072 }
00073 
00074 #endif /* HAVE_EIGEN */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation