Skip to content

Commit

Permalink
Finally added missing libshogun tests for DR preprocessors (no leaks)
Browse files Browse the repository at this point in the history
  • Loading branch information
lisitsyn committed Oct 7, 2011
1 parent b86e64f commit 5a4f2de
Show file tree
Hide file tree
Showing 10 changed files with 163 additions and 9 deletions.
4 changes: 4 additions & 0 deletions examples/undocumented/libshogun/Makefile
Expand Up @@ -43,6 +43,10 @@ TARGETS = basic_minimal classifier_libsvm classifier_minimal_svm \
preprocessor_hessianlocallylinearembedding \
preprocessor_kernellocallylinearembedding \
preprocessor_kernellocaltangentspacealignment \
preprocessor_multidimensionalscaling \
preprocessor_isomap \
preprocessor_diffusionmaps \
preprocessor_laplacianeigenmaps \

all: $(TARGETS)

Expand Down
38 changes: 38 additions & 0 deletions examples/undocumented/libshogun/preprocessor_diffusionmaps.cpp
@@ -0,0 +1,38 @@
/*
* 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) 2011 Sergey Lisitsyn
* Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society
*/

#include <shogun/base/init.h>
#include <shogun/features/SimpleFeatures.h>
#include <shogun/preprocessor/DiffusionMaps.h>

using namespace shogun;

int main(int argc, char** argv)
{
init_shogun();

int N = 100;
int dim = 3;
float64_t* matrix = new double[N*dim];
for (int i=0; i<N*dim; i++)
matrix[i] = i;

CSimpleFeatures<double>* features = new CSimpleFeatures<double>(SGMatrix<double>(matrix,dim,N));
SG_REF(features);
CDiffusionMaps* dmaps = new CDiffusionMaps();
dmaps->set_target_dim(2);
dmaps->set_t(10);
dmaps->parallel->set_num_threads(4);
dmaps->apply_to_feature_matrix(features);
SG_UNREF(dmaps);
SG_UNREF(features);
exit_shogun();
return 0;
}
Expand Up @@ -10,7 +10,6 @@

#include <shogun/base/init.h>
#include <shogun/features/SimpleFeatures.h>
#include <shogun/preprocessor/DimensionReductionPreprocessor.h>
#include <shogun/preprocessor/HessianLocallyLinearEmbedding.h>

using namespace shogun;
Expand Down
40 changes: 40 additions & 0 deletions examples/undocumented/libshogun/preprocessor_isomap.cpp
@@ -0,0 +1,40 @@
/*
* 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) 2011 Sergey Lisitsyn
* Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society
*/

#include <shogun/base/init.h>
#include <shogun/features/SimpleFeatures.h>
#include <shogun/preprocessor/DimensionReductionPreprocessor.h>
#include <shogun/preprocessor/Isomap.h>

using namespace shogun;

int main(int argc, char** argv)
{
init_shogun();

int N = 100;
int dim = 3;
float64_t* matrix = new double[N*dim];
for (int i=0; i<N*dim; i++)
matrix[i] = i;

CSimpleFeatures<double>* features = new CSimpleFeatures<double>(SGMatrix<double>(matrix,dim,N));
SG_REF(features);
CIsomap* isomap = new CIsomap();
isomap->set_target_dim(2);
isomap->set_landmark(true);
isomap->set_k(4);
isomap->parallel->set_num_threads(4);
isomap->apply_to_feature_matrix(features);
SG_UNREF(isomap);
SG_UNREF(features);
exit_shogun();
return 0;
}
Expand Up @@ -10,7 +10,6 @@

#include <shogun/base/init.h>
#include <shogun/features/SimpleFeatures.h>
#include <shogun/preprocessor/DimensionReductionPreprocessor.h>
#include <shogun/preprocessor/KernelLocallyLinearEmbedding.h>
#include <shogun/kernel/LinearKernel.h>

Expand All @@ -33,8 +32,8 @@ int main(int argc, char** argv)
klle->set_target_dim(2);
klle->set_k(4);
klle->set_kernel(kernel);
klle->apply_to_feature_matrix(features);
klle->parallel->set_num_threads(4);
klle->apply_to_feature_matrix(features);
SG_UNREF(klle);
SG_UNREF(features);
exit_shogun();
Expand Down
Expand Up @@ -10,7 +10,6 @@

#include <shogun/base/init.h>
#include <shogun/features/SimpleFeatures.h>
#include <shogun/preprocessor/DimensionReductionPreprocessor.h>
#include <shogun/preprocessor/KernelLocalTangentSpaceAlignment.h>
#include <shogun/kernel/LinearKernel.h>

Expand All @@ -33,8 +32,8 @@ int main(int argc, char** argv)
kltsa->set_target_dim(2);
kltsa->set_k(4);
kltsa->set_kernel(kernel);
kltsa->apply_to_feature_matrix(features);
kltsa->parallel->set_num_threads(4);
kltsa->apply_to_feature_matrix(features);
SG_UNREF(kltsa);
SG_UNREF(features);
exit_shogun();
Expand Down
@@ -0,0 +1,38 @@
/*
* 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) 2011 Sergey Lisitsyn
* Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society
*/

#include <shogun/base/init.h>
#include <shogun/features/SimpleFeatures.h>
#include <shogun/preprocessor/LaplacianEigenmaps.h>

using namespace shogun;

int main(int argc, char** argv)
{
init_shogun();

int N = 100;
int dim = 3;
float64_t* matrix = new double[N*dim];
for (int i=0; i<N*dim; i++)
matrix[i] = i;

CSimpleFeatures<double>* features = new CSimpleFeatures<double>(SGMatrix<double>(matrix,dim,N));
SG_REF(features);
CLaplacianEigenmaps* lem = new CLaplacianEigenmaps();
lem->set_target_dim(2);
lem->set_k(10);
lem->parallel->set_num_threads(4);
lem->apply_to_feature_matrix(features);
SG_UNREF(lem);
SG_UNREF(features);
exit_shogun();
return 0;
}
Expand Up @@ -10,7 +10,6 @@

#include <shogun/base/init.h>
#include <shogun/features/SimpleFeatures.h>
#include <shogun/preprocessor/DimensionReductionPreprocessor.h>
#include <shogun/preprocessor/LocallyLinearEmbedding.h>

using namespace shogun;
Expand All @@ -30,8 +29,8 @@ int main(int argc, char** argv)
CLocallyLinearEmbedding* lle = new CLocallyLinearEmbedding();
lle->set_target_dim(2);
lle->set_k(4);
lle->apply_to_feature_matrix(features);
lle->parallel->set_num_threads(4);
lle->apply_to_feature_matrix(features);
SG_UNREF(lle);
SG_UNREF(features);
exit_shogun();
Expand Down
Expand Up @@ -10,7 +10,6 @@

#include <shogun/base/init.h>
#include <shogun/features/SimpleFeatures.h>
#include <shogun/preprocessor/DimensionReductionPreprocessor.h>
#include <shogun/preprocessor/LocalTangentSpaceAlignment.h>

using namespace shogun;
Expand All @@ -30,8 +29,8 @@ int main(int argc, char** argv)
CLocalTangentSpaceAlignment* ltsa = new CLocalTangentSpaceAlignment();
ltsa->set_target_dim(2);
ltsa->set_k(4);
ltsa->apply_to_feature_matrix(features);
ltsa->parallel->set_num_threads(4);
ltsa->apply_to_feature_matrix(features);
SG_UNREF(ltsa);
SG_UNREF(features);
exit_shogun();
Expand Down
@@ -0,0 +1,39 @@
/*
* 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) 2011 Sergey Lisitsyn
* Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society
*/

#include <shogun/base/init.h>
#include <shogun/features/SimpleFeatures.h>
#include <shogun/preprocessor/DimensionReductionPreprocessor.h>
#include <shogun/preprocessor/MultidimensionalScaling.h>

using namespace shogun;

int main(int argc, char** argv)
{
init_shogun();

int N = 100;
int dim = 3;
float64_t* matrix = new double[N*dim];
for (int i=0; i<N*dim; i++)
matrix[i] = i;

CSimpleFeatures<double>* features = new CSimpleFeatures<double>(SGMatrix<double>(matrix,dim,N));
SG_REF(features);
CMultidimensionalScaling* mds = new CMultidimensionalScaling();
mds->set_target_dim(2);
mds->set_landmark(true);
mds->parallel->set_num_threads(4);
mds->apply_to_feature_matrix(features);
SG_UNREF(mds);
SG_UNREF(features);
exit_shogun();
return 0;
}

0 comments on commit 5a4f2de

Please sign in to comment.