Skip to content

Commit

Permalink
Introduced converters module, moved DR preprocessors to it, fixed exa…
Browse files Browse the repository at this point in the history
…mples, updated other classes according to changes
  • Loading branch information
lisitsyn committed Oct 13, 2011
1 parent 78c8694 commit 04b6de9
Show file tree
Hide file tree
Showing 75 changed files with 734 additions and 736 deletions.
@@ -1,6 +1,6 @@
using System;

public class preprocessor_classicisomap_modular {
public class converter_classicisomap_modular {
public static void Main() {
modshogun.init_shogun_with_defaults();

Expand All @@ -10,7 +10,7 @@ public class preprocessor_classicisomap_modular {

Isomap preprocessor = new Isomap();
preprocessor.set_target_dim(1);
preprocessor.apply_to_feature_matrix(features);
preprocessor.apply(features);

modshogun.exit_shogun();
}
Expand Down
@@ -1,6 +1,6 @@
using System;

public class preprocessor_locallylinearembedding_modular {
public class converter_locallylinearembedding_modular {
public static void Main() {

modshogun.init_shogun_with_defaults();
Expand All @@ -10,7 +10,7 @@ public class preprocessor_locallylinearembedding_modular {
RealFeatures features = new RealFeatures(data);
LocallyLinearEmbedding preprocessor = new LocallyLinearEmbedding();
preprocessor.set_target_dim(1);
preprocessor.apply_to_feature_matrix(features);
preprocessor.apply(features);

modshogun.exit_shogun();
}
Expand Down
@@ -1,6 +1,6 @@
using System;

public class preprocessor_multidimensionalscaling_modular {
public class converter_multidimensionalscaling_modular {
public static void Main() {
modshogun.init_shogun_with_defaults();

Expand All @@ -11,7 +11,7 @@ public class preprocessor_multidimensionalscaling_modular {
mds.set_target_dim(1);
mds.set_landmark(false);

mds.apply_to_feature_matrix(features);
mds.apply(features);

modshogun.exit_shogun();
}
Expand Down
@@ -1,7 +1,7 @@
import org.shogun.*;
import org.jblas.*;

public class preprocessor_isomap_modular {
public class converter_isomap_modular {
static {
System.loadLibrary("modshogun");
}
Expand All @@ -16,7 +16,7 @@ public static void main(String argv[]) {
isomap.set_target_dim(1);
isomap.set_k(6);
isomap.set_landmark(false);
isomap.apply_to_feature_matrix(features);
isomap.apply(features);

modshogun.exit_shogun();
}
Expand Down
@@ -1,7 +1,7 @@
import org.shogun.*;
import org.jblas.*;

public class preprocessor_locallylinearembedding_modular {
public class converter_locallylinearembedding_modular {
static {
System.loadLibrary("modshogun");
}
Expand All @@ -14,7 +14,7 @@ public static void main(String argv[]) {
RealFeatures features = new RealFeatures(data);
LocallyLinearEmbedding preprocessor = new LocallyLinearEmbedding();
preprocessor.set_target_dim(1);
preprocessor.apply_to_feature_matrix(features);
preprocessor.apply(features);

modshogun.exit_shogun();
}
Expand Down
@@ -1,7 +1,7 @@
import org.shogun.*;
import org.jblas.*;

public class preprocessor_multidimensionalscaling_modular {
public class converter_multidimensionalscaling_modular {
static {
System.loadLibrary("modshogun");
}
Expand All @@ -16,7 +16,7 @@ public static void main(String argv[]) {
mds.set_target_dim(1);
mds.set_landmark(false);

mds.apply_to_feature_matrix(features);
mds.apply(features);

modshogun.exit_shogun();
}
Expand Down
18 changes: 9 additions & 9 deletions examples/undocumented/libshogun/Makefile
Expand Up @@ -38,15 +38,15 @@ TARGETS = basic_minimal classifier_libsvm classifier_minimal_svm \
library_fibonacci_heap \
library_hashset \
mathematics_lapack \
preprocessor_locallylinearembedding \
preprocessor_localtangentspacealignment \
preprocessor_hessianlocallylinearembedding \
preprocessor_kernellocallylinearembedding \
preprocessor_kernellocaltangentspacealignment \
preprocessor_multidimensionalscaling \
preprocessor_isomap \
preprocessor_diffusionmaps \
preprocessor_laplacianeigenmaps \
converter_locallylinearembedding \
converter_localtangentspacealignment \
converter_hessianlocallylinearembedding \
converter_kernellocallylinearembedding \
converter_kernellocaltangentspacealignment \
converter_multidimensionalscaling \
converter_isomap \
converter_diffusionmaps \
converter_laplacianeigenmaps \

all: $(TARGETS)

Expand Down
Expand Up @@ -10,7 +10,7 @@

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

using namespace shogun;

Expand All @@ -30,7 +30,8 @@ int main(int argc, char** argv)
dmaps->set_target_dim(2);
dmaps->set_t(10);
dmaps->parallel->set_num_threads(4);
dmaps->apply_to_feature_matrix(features);
CSimpleFeatures<double>* embedding = dmaps->apply(features);
SG_UNREF(embedding);
SG_UNREF(dmaps);
SG_UNREF(features);
exit_shogun();
Expand Down
Expand Up @@ -10,7 +10,7 @@

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

using namespace shogun;

Expand All @@ -29,8 +29,9 @@ int main(int argc, char** argv)
CHessianLocallyLinearEmbedding* hlle = new CHessianLocallyLinearEmbedding();
hlle->set_target_dim(2);
hlle->set_k(8);
hlle->apply_to_feature_matrix(features);
hlle->parallel->set_num_threads(4);
CSimpleFeatures<double>* embedding = hlle->apply(features);
SG_UNREF(embedding);
SG_UNREF(hlle);
SG_UNREF(features);
exit_shogun();
Expand Down
Expand Up @@ -10,8 +10,7 @@

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

using namespace shogun;

Expand All @@ -32,7 +31,8 @@ int main(int argc, char** argv)
isomap->set_landmark(true);
isomap->set_k(4);
isomap->parallel->set_num_threads(4);
isomap->apply_to_feature_matrix(features);
CSimpleFeatures<double>* embedding = isomap->apply(features);
SG_UNREF(embedding);
SG_UNREF(isomap);
SG_UNREF(features);
exit_shogun();
Expand Down
Expand Up @@ -10,7 +10,7 @@

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

using namespace shogun;
Expand All @@ -33,7 +33,8 @@ int main(int argc, char** argv)
klle->set_k(4);
klle->set_kernel(kernel);
klle->parallel->set_num_threads(4);
klle->apply_to_feature_matrix(features);
CSimpleFeatures<double>* embedding = klle->apply(features);
SG_UNREF(embedding);
SG_UNREF(klle);
SG_UNREF(features);
exit_shogun();
Expand Down
Expand Up @@ -10,7 +10,7 @@

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

using namespace shogun;
Expand All @@ -33,7 +33,8 @@ int main(int argc, char** argv)
kltsa->set_k(4);
kltsa->set_kernel(kernel);
kltsa->parallel->set_num_threads(4);
kltsa->apply_to_feature_matrix(features);
CSimpleFeatures<double>* embedding = kltsa->apply(features);
SG_UNREF(embedding);
SG_UNREF(kltsa);
SG_UNREF(features);
exit_shogun();
Expand Down
Expand Up @@ -10,7 +10,7 @@

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

using namespace shogun;

Expand All @@ -30,7 +30,8 @@ int main(int argc, char** argv)
lem->set_target_dim(2);
lem->set_k(10);
lem->parallel->set_num_threads(4);
lem->apply_to_feature_matrix(features);
CSimpleFeatures<double>* embedding = lem->apply(features);
SG_UNREF(embedding);
SG_UNREF(lem);
SG_UNREF(features);
exit_shogun();
Expand Down
Expand Up @@ -10,7 +10,7 @@

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

using namespace shogun;

Expand All @@ -30,7 +30,8 @@ int main(int argc, char** argv)
lle->set_target_dim(2);
lle->set_k(4);
lle->parallel->set_num_threads(4);
lle->apply_to_feature_matrix(features);
CSimpleFeatures<double>* embedding = lle->apply(features);
SG_UNREF(embedding);
SG_UNREF(lle);
SG_UNREF(features);
exit_shogun();
Expand Down
Expand Up @@ -10,7 +10,7 @@

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

using namespace shogun;

Expand All @@ -30,7 +30,8 @@ int main(int argc, char** argv)
ltsa->set_target_dim(2);
ltsa->set_k(4);
ltsa->parallel->set_num_threads(4);
ltsa->apply_to_feature_matrix(features);
CSimpleFeatures<double>* embedding = ltsa->apply(features);
SG_UNREF(embedding);
SG_UNREF(ltsa);
SG_UNREF(features);
exit_shogun();
Expand Down
Expand Up @@ -10,8 +10,7 @@

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

using namespace shogun;

Expand All @@ -31,7 +30,8 @@ int main(int argc, char** argv)
mds->set_target_dim(2);
mds->set_landmark(true);
mds->parallel->set_num_threads(4);
mds->apply_to_feature_matrix(features);
CSimpleFeatures<double>* embedding = mds->apply(features);
SG_UNREF(embedding);
SG_UNREF(mds);
SG_UNREF(features);
exit_shogun();
Expand Down
@@ -0,0 +1,27 @@
from tools.load import LoadMatrix

lm=LoadMatrix()
data = lm.load_numbers('../data/fm_train_real.dat')

parameter_list = [[data,10],[data,20]]

def converter_diffusionmaps_modular(data,t):
from shogun.Features import RealFeatures
from shogun.Converter import DiffusionMaps
from shogun.Kernel import GaussianKernel

features = RealFeatures(data)

converter = DiffusionMaps()
converter.set_target_dim(1)
converter.set_kernel(GaussianKernel(10,10.0))
converter.set_t(t)
converter.apply(features)

return features


if __name__=='__main__':
print 'DiffusionMaps'
converter_diffusionmaps_modular(*parameter_list[0])

@@ -0,0 +1,25 @@
from tools.load import LoadMatrix

lm=LoadMatrix()
data = lm.load_numbers('../data/fm_train_real.dat')

parameter_list = [[data,10],[data,20]]

def converter_hessianlocallylinearembedding_modular(data,k):
from shogun.Features import RealFeatures
from shogun.Converter import HessianLocallyLinearEmbedding

features = RealFeatures(data)

converter = HessianLocallyLinearEmbedding()
converter.set_target_dim(1)
converter.set_k(k)
converter.apply(features)

return features


if __name__=='__main__':
print 'HessianLocallyLinearEmbedding'
converter_hessianlocallylinearembedding_modular(*parameter_list[0])

27 changes: 27 additions & 0 deletions examples/undocumented/python_modular/converter_isomap_modular.py
@@ -0,0 +1,27 @@
from tools.load import LoadMatrix

lm=LoadMatrix()
data = lm.load_numbers('../data/fm_train_real.dat')

parameter_list = [[data]]

def converter_isomap_modular(data):
from shogun.Features import RealFeatures
from shogun.Converter import Isomap

features = RealFeatures(data)

converter = Isomap()
converter.set_landmark(True)
converter.set_landmark_number(5)
converter.set_k(6)
converter.set_target_dim(1)
converter.apply(features)

return features


if __name__=='__main__':
print 'Isomap'
converter_isomap_modular(*parameter_list[0])

0 comments on commit 04b6de9

Please sign in to comment.