static void Main(string[] argv)
    {
        modshogun.init_shogun_with_defaults();

        int num = 1000;
        double dist = 1.0;
        double width = 2.1;
        double C = 1.0;

        DoubleMatrix offs =ones(2, num).mmul(dist);
        DoubleMatrix x = randn(2, num).sub(offs);
        DoubleMatrix y = randn(2, num).add(offs);
        DoubleMatrix traindata_real = concatHorizontally(x, y);

        DoubleMatrix m = randn(2, num).sub(offs);
        DoubleMatrix n = randn(2, num).add(offs);
        DoubleMatrix testdata_real = concatHorizontally(m, n);

        DoubleMatrix o = ones(1,num);
        DoubleMatrix trainlab = concatHorizontally(o.neg(), o);
        DoubleMatrix testlab = concatHorizontally(o.neg(), o);

        RealFeatures feats_train = new RealFeatures(traindata_real);
        RealFeatures feats_test = new RealFeatures(testdata_real);
        GaussianKernel kernel = new GaussianKernel(feats_train, feats_train, width);
        Labels labels = new Labels(trainlab);
        LibSVM svm = new LibSVM(C, kernel, labels);
        svm.train();

        DoubleMatrix @out = svm.apply(feats_test).get_labels();

        Console.WriteLine("Mean Error = " + signum(@out).ne(testlab).mean());
        modshogun.exit_shogun();
    }
    static void Main(string[] argv)
    {
        modshogun.init_shogun_with_defaults();
        double width = 2.1;
        double epsilon = 1e-5;
        double C = 1.0;

        DoubleMatrix traindata_real = Load.load_numbers("../data/fm_train_real.dat");
        DoubleMatrix testdata_real = Load.load_numbers("../data/fm_test_real.dat");

        DoubleMatrix trainlab = Load.load_labels("../data/label_train_twoclass.dat");

        RealFeatures feats_train = new RealFeatures();
        feats_train.set_feature_matrix(traindata_real);
        RealFeatures feats_test = new RealFeatures();
        feats_test.set_feature_matrix(testdata_real);

        GaussianKernel kernel = new GaussianKernel(feats_train, feats_train, width);

        Labels labels = new Labels(trainlab);

        LibSVM svm = new LibSVM(C, kernel, labels);
        svm.set_epsilon(epsilon);
        svm.train();

        kernel.init(feats_train, feats_test);
        DoubleMatrix out_labels = svm.apply().get_labels();
        Console.WriteLine(out_labels.ToString());

        modshogun.exit_shogun();
    }
    public static void Main()
    {
        modshogun.init_shogun_with_defaults();
        double width = 2.1;
        double epsilon = 1e-5;
        double C = 1.0;

        double[,] traindata_real = Load.load_numbers("../data/fm_train_real.dat");
        double[,] testdata_real = Load.load_numbers("../data/fm_test_real.dat");

        double[] trainlab = Load.load_labels("../data/label_train_twoclass.dat");

        RealFeatures feats_train = new RealFeatures();
        feats_train.set_feature_matrix(traindata_real);
        RealFeatures feats_test = new RealFeatures();
        feats_test.set_feature_matrix(testdata_real);

        GaussianKernel kernel = new GaussianKernel(feats_train, feats_train, width);

        BinaryLabels labels = new BinaryLabels(trainlab);

        LibSVM svm = new LibSVM(C, kernel, labels);
        svm.set_epsilon(epsilon);
        svm.train();

        kernel.init(feats_train, feats_test);
        double[] out_labels = LabelsFactory.to_binary(svm.apply()).get_labels();

        foreach(double item in out_labels) {
            Console.Write(item);
        }

        modshogun.exit_shogun();
    }
	public static void Main() {
		modshogun.init_shogun_with_defaults();

		int num = 1000;
		double dist = 1.0;
		double width = 2.1;
		double C = 1.0;

		Random RandomNumber = new Random();

		double[,] traindata_real = new double[2, num * 2];
		for (int i = 0; i < num; i ++) {
			traindata_real[0, i] = RandomNumber.NextDouble() - dist;
			traindata_real[0, i + num] = RandomNumber.NextDouble() + dist;
			traindata_real[1, i] = RandomNumber.NextDouble() - dist;
			traindata_real[1, i + num] = RandomNumber.NextDouble() + dist;
		}

		double[,] testdata_real = new double[2, num * 2];
		for (int i = 0; i < num; i ++) {
			testdata_real[0, i] = RandomNumber.NextDouble() - dist;
			testdata_real[0, i + num] = RandomNumber.NextDouble() + dist;
			testdata_real[1, i] = RandomNumber.NextDouble() - dist;
			testdata_real[1, i + num] = RandomNumber.NextDouble() + dist;
		}

		double[] trainlab = new double[num * 2];
		for (int i = 0; i < num; i ++) {
			trainlab[i] = -1;
			trainlab[i + num] = 1;
		}

		double[] testlab = new double[num * 2];
		for (int i = 0; i < num; i ++) {
			testlab[i] = -1;
			testlab[i + num] = 1;
		}

		RealFeatures feats_train = new RealFeatures(traindata_real);
		RealFeatures feats_test = new RealFeatures(testdata_real);
		GaussianKernel kernel = new GaussianKernel(feats_train, feats_train, width);
		BinaryLabels labels = new BinaryLabels(trainlab);
		LibSVM svm = new LibSVM(C, kernel, labels);
		svm.train();

		double[] result = LabelsFactory.to_binary(svm.apply(feats_test)).get_labels();

		int err_num = 0;
		for (int i = 0; i < num; i++) {
			if (result[i] > 0) {
				err_num += 1;
			}
			if (result[i+num] < 0) {
				err_num += 1;
			}
		}

		double testerr=err_num/(2*num);
		Console.WriteLine(testerr);
	}
    static void Main(string[] argv)
    {
        modshogun.init_shogun_with_defaults();
        double width = 2.1;
        double epsilon = 1e-5;
        double C = 1.0;

        DoubleMatrix traindata_real = Load.load_numbers("../data/fm_train_real.dat");
        DoubleMatrix testdata_real = Load.load_numbers("../data/fm_test_real.dat");

        DoubleMatrix trainlab = Load.load_labels("../data/label_train_twoclass.dat");

        CombinedKernel kernel = new CombinedKernel();
        CombinedFeatures feats_train = new CombinedFeatures();

        RealFeatures tfeats = new RealFeatures(traindata_real);
        PolyKernel tkernel = new PolyKernel(10,3);
        tkernel.init(tfeats, tfeats);
        DoubleMatrix K = tkernel.get_kernel_matrix();
        kernel.append_kernel(new CustomKernel(K));

        RealFeatures subkfeats_train = new RealFeatures(traindata_real);
        feats_train.append_feature_obj(subkfeats_train);
        PolyKernel subkernel = new PolyKernel(10,2);
        kernel.append_kernel(subkernel);

        kernel.init(feats_train, feats_train);

        Labels labels = new Labels(trainlab);

        LibSVM svm = new LibSVM(C, kernel, labels);
        svm.train();

        CombinedKernel kernel_pred = new CombinedKernel();
        CombinedFeatures feats_pred = new CombinedFeatures();

        RealFeatures pfeats = new RealFeatures(testdata_real);
        PolyKernel tkernel_pred = new PolyKernel(10,3);
        tkernel_pred.init(tfeats, pfeats);
        DoubleMatrix KK = tkernel.get_kernel_matrix();
        kernel_pred.append_kernel(new CustomKernel(KK));

        RealFeatures subkfeats_test = new RealFeatures(testdata_real);
        feats_pred.append_feature_obj(subkfeats_train);
        PolyKernel subkernel_pred = new PolyKernel(10,2);
        kernel_pred.append_kernel(subkernel_pred);

        kernel_pred.init(feats_train, feats_pred);

        svm.set_kernel(kernel_pred);
        svm.apply();
        DoubleMatrix km_train =kernel.get_kernel_matrix();
        Console.WriteLine(km_train.ToString());

        modshogun.exit_shogun();
    }
    public static void Main()
    {
        modshogun.init_shogun_with_defaults();
        double width   = 2.1;
        double epsilon = 1e-5;
        double C       = 1.0;

        double[,] traindata_real = Load.load_numbers("../data/fm_train_real.dat");
        double[,] testdata_real  = Load.load_numbers("../data/fm_test_real.dat");

        double[] trainlab = Load.load_labels("../data/label_train_twoclass.dat");

        RealFeatures feats_train = new RealFeatures();

        feats_train.set_feature_matrix(traindata_real);
        RealFeatures feats_test = new RealFeatures();

        feats_test.set_feature_matrix(testdata_real);

        GaussianKernel kernel = new GaussianKernel(feats_train, feats_train, width);

        BinaryLabels labels = new BinaryLabels(trainlab);

        LibSVM svm = new LibSVM(C, kernel, labels);

        svm.set_epsilon(epsilon);
        svm.train();

        kernel.init(feats_train, feats_test);
        double[] out_labels = BinaryLabels.obtain_from_generic(svm.apply()).get_labels();

        foreach (double item in out_labels)
        {
            Console.Write(item);
        }

        modshogun.exit_shogun();
    }
    public static void Main()
    {
        modshogun.init_shogun_with_defaults();

        int    num   = 1000;
        double dist  = 1.0;
        double width = 2.1;
        double C     = 1.0;

        Random RandomNumber = new Random();

        double[,] traindata_real = new double[2, num * 2];
        for (int i = 0; i < num; i++)
        {
            traindata_real[0, i]       = RandomNumber.NextDouble() - dist;
            traindata_real[0, i + num] = RandomNumber.NextDouble() + dist;
            traindata_real[1, i]       = RandomNumber.NextDouble() - dist;
            traindata_real[1, i + num] = RandomNumber.NextDouble() + dist;
        }

        double[,] testdata_real = new double[2, num * 2];
        for (int i = 0; i < num; i++)
        {
            testdata_real[0, i]       = RandomNumber.NextDouble() - dist;
            testdata_real[0, i + num] = RandomNumber.NextDouble() + dist;
            testdata_real[1, i]       = RandomNumber.NextDouble() - dist;
            testdata_real[1, i + num] = RandomNumber.NextDouble() + dist;
        }

        double[] trainlab = new double[num * 2];
        for (int i = 0; i < num; i++)
        {
            trainlab[i]       = -1;
            trainlab[i + num] = 1;
        }

        double[] testlab = new double[num * 2];
        for (int i = 0; i < num; i++)
        {
            testlab[i]       = -1;
            testlab[i + num] = 1;
        }

        RealFeatures   feats_train = new RealFeatures(traindata_real);
        RealFeatures   feats_test  = new RealFeatures(testdata_real);
        GaussianKernel kernel      = new GaussianKernel(feats_train, feats_train, width);
        BinaryLabels   labels      = new BinaryLabels(trainlab);
        LibSVM         svm         = new LibSVM(C, kernel, labels);

        svm.train();

        double[] result = BinaryLabels.obtain_from_generic(svm.apply(feats_test)).get_labels();

        int err_num = 0;

        for (int i = 0; i < num; i++)
        {
            if (result[i] > 0)
            {
                err_num += 1;
            }
            if (result[i + num] < 0)
            {
                err_num += 1;
            }
        }

        double testerr = err_num / (2 * num);

        Console.WriteLine(testerr);
        modshogun.exit_shogun();
    }