public static void main(String argv[]) { modshogun.init_shogun_with_defaults(); double width = 1.4; int size_cache = 10; DoubleMatrix traindata_real = Load.load_numbers("../data/fm_train_real.dat"); DoubleMatrix testdata_real = Load.load_numbers("../data/fm_test_real.dat"); RealFeatures feats_train = new RealFeatures(traindata_real); RealFeatures feats_test = new RealFeatures(testdata_real); NormOne preproc = new NormOne(); preproc.init(feats_train); feats_train.add_preprocessor(preproc); feats_train.apply_preprocessor(); feats_test.add_preprocessor(preproc); feats_test.apply_preprocessor(); Chi2Kernel kernel = new Chi2Kernel(feats_train, feats_train, width, size_cache); DoubleMatrix km_train = kernel.get_kernel_matrix(); kernel.init(feats_train, feats_test); DoubleMatrix km_test = kernel.get_kernel_matrix(); System.out.println(km_train.toString()); System.out.println(km_test.toString()); }
public static void main(String argv[]) { modshogun.init_shogun_with_defaults(); int dim = 7; DoubleMatrix data = DoubleMatrix.rand(dim, dim); RealFeatures feats = new RealFeatures(data); DoubleMatrix data_T = data.transpose(); DoubleMatrix symdata = data.add(data_T); int cols = (1 + dim) * dim / 2; DoubleMatrix lowertriangle = DoubleMatrix.zeros(1, cols); int count = 0; for (int i = 0; i < dim; i++) { for (int j = 0; j < dim; j++) { if (j <= i) { lowertriangle.put(0, count++, symdata.get(i, j)); } } } CustomKernel kernel = new CustomKernel(); kernel.set_triangle_kernel_matrix_from_triangle(lowertriangle); DoubleMatrix km_triangletriangle = kernel.get_kernel_matrix(); kernel.set_triangle_kernel_matrix_from_full(symdata); DoubleMatrix km_fulltriangle = kernel.get_kernel_matrix(); kernel.set_full_kernel_matrix_from_full(data); DoubleMatrix km_fullfull = kernel.get_kernel_matrix(); modshogun.exit_shogun(); }
public static void main(String argv[]) { modshogun.init_shogun_with_defaults(); DoubleMatrix traindata_real = Load.load_numbers("../data/fm_train_real.dat"); DoubleMatrix testdata_real = Load.load_numbers("../data/fm_test_real.dat"); RealFeatures feats_train = new RealFeatures(traindata_real); RealFeatures feats_test = new RealFeatures(testdata_real); EuclideanDistance distance = new EuclideanDistance(feats_train, feats_train); DoubleMatrix dm_train = distance.get_distance_matrix(); distance.init(feats_train, feats_test); DoubleMatrix dm_test = distance.get_distance_matrix(); System.out.println(dm_train.toString()); System.out.println(dm_test.toString()); }
public static void main(String argv[]) { modshogun.init_shogun_with_defaults(); double c = 23; DummyFeatures feats_train = new DummyFeatures(10); DummyFeatures feats_test = new DummyFeatures(17); ConstKernel kernel = new ConstKernel(feats_train, feats_train, c); DoubleMatrix km_train = kernel.get_kernel_matrix(); kernel.init(feats_train, feats_test); DoubleMatrix km_test = kernel.get_kernel_matrix(); System.out.println(km_train.toString()); System.out.println(km_test.toString()); modshogun.exit_shogun(); }