@@ -0,0 +1,2235 @@
+import org.shogun.*;%0Aimport org.jblas.*;%0Aimport static org.jblas.MatrixFunctions.signum;%0Aimport static org.jblas.DoubleMatrix.concatHorizontally;%0Aimport static org.jblas.DoubleMatrix.ones;%0Aimport static org.jblas.DoubleMatrix.randn;%0Aimport java.util.ArrayList;%0Aimport java.io.*;%0A%0Apublic class serialization_svmlight_modular %7B%0A%09static %7B%0A%09%09System.loadLibrary(%22Features%22);%0A%09%09System.loadLibrary(%22Classifier%22);%0A%09%09System.loadLibrary(%22Kernel%22);%0A%09%7D%0A%09%0A%09public static void save(String fname, Object obj) %7B%0A%09%09try %7B%0A%09%09%09FileOutputStream fs = new FileOutputStream(fname);%0A%09%09%09ObjectOutputStream out =  new ObjectOutputStream(fs);%0A%09%09%09out.writeObject(obj);%0A%09%09%09out.close();%0A        %7D%0A%09%09catch(Exception ex)%7B%0A%09%09%09ex.printStackTrace();  %0A        %7D%0A%09%7D%0A%0A%09public static Object load(String fname) %7B%0A%09%09Object r = null;%09%09%0A%09%09try %7B%0A%09%09%09FileInputStream fs = new FileInputStream(fname);%0A%09%09%09ObjectInputStream in =  new ObjectInputStream(fs);%0A%09%09%09r = in.readObject();%0A%09%09%09in.close();%0A%09%09%09return r;%0A        %7D%0A%09%09catch(Exception ex)%7B%0A%09%09%09ex.printStackTrace();  %0A        %7D%0A%09%09return r;%0A%09%7D%0A%09public static void main(String argv%5B%5D) %7B%0A%09%09Features.init_shogun_with_defaults();%0A%0A%09%09int num = 1000;%0A%09%09double dist = 1.0;%0A%09%09double width = 2.1;%0A%09%09double C = 1.0;%0A%0A%09%09DoubleMatrix offs=ones(2, num).mmul(dist);%0A%09%09DoubleMatrix x = randn(2, num).sub(offs);%0A%09%09DoubleMatrix y = randn(2, num).add(offs);%0A%09%09DoubleMatrix traindata_real = concatHorizontally(x, y);%0A%0A%09%09DoubleMatrix m = randn(2, num).sub(offs);%0A%09%09DoubleMatrix n = randn(2, num).add(offs);%0A%09%09DoubleMatrix testdata_real = concatHorizontally(m, n);%0A%0A%09%09DoubleMatrix o = ones(1,num);%0A%09%09DoubleMatrix trainlab = concatHorizontally(o.neg(), o);%0A%09%09DoubleMatrix testlab = concatHorizontally(o.neg(), o);%0A%0A%09%09RealFeatures feats_train = new RealFeatures(traindata_real);%0A%09%09RealFeatures feats_test = new RealFeatures(testdata_real);%0A%09%09GaussianKernel kernel = new GaussianKernel(feats_train, feats_train, width);%0A%09%09Labels labels = new Labels(trainlab);%0A%09%09SVMLight svm = new SVMLight(C, kernel, labels);%0A%09%09svm.train();%0A%0A%09%09ArrayList result = new ArrayList();%0A%09%09result.add(svm);%0A%09%09String fname = %22out.txt%22;%0A%09%09save(fname, (Serializable)result);%0A%09%09ArrayList r = (ArrayList)load(fname);%0A%09%09SVMLight svm2 = (SVMLight)r.get(0);%0A%0A%09%09Features.exit_shogun();%0A%09%7D%0A%7D%0A

add serialization_svmlight_modular