EmbeddingConverter.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 Sergey Lisitsyn
00008  * Copyright (C) 2011 Sergey Lisitsyn
00009  */
00010 
00011 #include <shogun/converter/EmbeddingConverter.h>
00012 #include <shogun/features/SimpleFeatures.h>
00013 #include <shogun/kernel/LinearKernel.h>
00014 #include <shogun/distance/EuclidianDistance.h>
00015 
00016 using namespace shogun;
00017 
00018 namespace shogun 
00019 {
00020 CEmbeddingConverter::CEmbeddingConverter()
00021 : CConverter()
00022 {
00023     m_target_dim = 1;
00024     m_distance = new CEuclidianDistance();
00025     m_kernel = new CLinearKernel();
00026 
00027     init();
00028 }
00029 
00030 CEmbeddingConverter::~CEmbeddingConverter() 
00031 {
00032     SG_UNREF(m_distance);
00033     SG_UNREF(m_kernel);
00034 }
00035 
00036 CSimpleFeatures<float64_t>* CEmbeddingConverter::embed(CFeatures* features)
00037 {
00038     return (CSimpleFeatures<float64_t>*)apply(features);
00039 }
00040 
00041 void CEmbeddingConverter::set_target_dim(int32_t dim)
00042 {
00043     ASSERT(dim>0);
00044     m_target_dim = dim;
00045 }
00046 
00047 int32_t CEmbeddingConverter::get_target_dim() const
00048 {
00049     return m_target_dim;
00050 }
00051 
00052 void CEmbeddingConverter::set_distance(CDistance* distance)
00053 {
00054     SG_UNREF(m_distance);
00055     SG_REF(distance);
00056     m_distance = distance;
00057 }
00058 
00059 CDistance* CEmbeddingConverter::get_distance() const
00060 {
00061     SG_REF(m_distance);
00062     return m_distance;
00063 }
00064 
00065 void CEmbeddingConverter::set_kernel(CKernel* kernel)
00066 {
00067     SG_UNREF(m_kernel);
00068     SG_REF(kernel);
00069     m_kernel = kernel;
00070 }
00071 
00072 CKernel* CEmbeddingConverter::get_kernel() const
00073 {
00074     SG_REF(m_kernel);
00075     return m_kernel;
00076 }
00077 
00078 void CEmbeddingConverter::init()
00079 {
00080     this->m_parameters->add(&m_target_dim, "target_dim",
00081                             "target dimensionality of preprocessor");
00082     this->m_parameters->add((CSGObject**)&m_distance, "distance",
00083                             "distance to be used for embedding");
00084     this->m_parameters->add((CSGObject**)&m_kernel, "kernel",
00085                             "kernel to be used for embedding");
00086 }
00087 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation