Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added libshogun examples for KLTSA and KLLE
  • Loading branch information
lisitsyn committed Oct 7, 2011
1 parent a4454cb commit b86e64f
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 0 deletions.
2 changes: 2 additions & 0 deletions examples/undocumented/libshogun/Makefile
Expand Up @@ -41,6 +41,8 @@ TARGETS = basic_minimal classifier_libsvm classifier_minimal_svm \
preprocessor_locallylinearembedding \
preprocessor_localtangentspacealignment \
preprocessor_hessianlocallylinearembedding \
preprocessor_kernellocallylinearembedding \
preprocessor_kernellocaltangentspacealignment \

all: $(TARGETS)

Expand Down
@@ -0,0 +1,42 @@
/*
* 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/KernelLocallyLinearEmbedding.h>
#include <shogun/kernel/LinearKernel.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);
CKernelLocallyLinearEmbedding* klle = new CKernelLocallyLinearEmbedding();
CKernel* kernel = new CLinearKernel();
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);
SG_UNREF(klle);
SG_UNREF(features);
exit_shogun();
return 0;
}
@@ -0,0 +1,42 @@
/*
* 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/KernelLocalTangentSpaceAlignment.h>
#include <shogun/kernel/LinearKernel.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);
CKernelLocalTangentSpaceAlignment* kltsa = new CKernelLocalTangentSpaceAlignment();
CKernel* kernel = new CLinearKernel();
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);
SG_UNREF(kltsa);
SG_UNREF(features);
exit_shogun();
return 0;
}

0 comments on commit b86e64f

Please sign in to comment.