public static void Main() {
		bool reverse = false;
		modshogun.init_shogun_with_defaults();
		int order = 3;
		int gap = 4;

		String[] fm_train_dna = Load.load_dna("../data/fm_train_dna.dat");

		StringCharFeatures charfeat = new StringCharFeatures(fm_train_dna, EAlphabet.DNA);
		StringWordFeatures feats = new StringWordFeatures(charfeat.get_alphabet());
		feats.obtain_from_char(charfeat, order-1, order, gap, reverse);

		Histogram histo = new Histogram(feats);
		histo.train();

		double[] histogram = histo.get_histogram();

		foreach(double item in histogram) {
			Console.Write(item);
		}
		//int  num_examples = feats.get_num_vectors();
		//int num_param = histo.get_num_model_parameters();

		//double[,] out_likelihood = histo.get_log_likelihood();
		//double out_sample = histo.get_log_likelihood_sample();

		modshogun.exit_shogun();
	}
	public static void Main() {
		modshogun.init_shogun_with_defaults();
		bool reverse = false;
		int order = 3;
		int gap = 0;

		string[] fm_train_dna = Load.load_dna("../data/fm_train_dna.dat");
		string[] fm_test_dna = Load.load_dna("../data/fm_test_dna.dat");

		StringCharFeatures charfeat = new StringCharFeatures(fm_train_dna, EAlphabet.DNA);
		StringWordFeatures feats_train = new StringWordFeatures(charfeat.get_alphabet());
		feats_train.obtain_from_char(charfeat, order-1, order, gap, reverse);

		charfeat = new StringCharFeatures(fm_test_dna, EAlphabet.DNA);
		StringWordFeatures feats_test = new StringWordFeatures(charfeat.get_alphabet());
		feats_test.obtain_from_char(charfeat, order-1, order, gap, reverse);

		SortWordString preproc = new SortWordString();
		preproc.init(feats_train);
		feats_train.add_preprocessor(preproc);
		feats_train.apply_preprocessor();
		feats_test.add_preprocessor(preproc);
		feats_test.apply_preprocessor();

		CommWordStringKernel kernel = new CommWordStringKernel(feats_train, feats_train, false);

		double[,] km_train = kernel.get_kernel_matrix();
		kernel.init(feats_train, feats_test);
		double[,] km_test = kernel.get_kernel_matrix();

		modshogun.exit_shogun();
	}
	public static void Main() {
		modshogun.init_shogun_with_defaults();
		int order = 3;
		int gap = 0;
		bool reverse = false;
		bool use_sign = false;

		String[] fm_train_dna = Load.load_dna("../data/fm_train_dna.dat");
		String[] fm_test_dna = Load.load_dna("../data/fm_test_dna.dat");
		double[] fm_test_real = Load.load_labels("../data/fm_test_real.dat");

		StringCharFeatures charfeat = new StringCharFeatures(EAlphabet.DNA);
		charfeat.set_features(fm_train_dna);
		StringWordFeatures feats_train = new StringWordFeatures(charfeat.get_alphabet());
		feats_train.obtain_from_char(charfeat, order-1, order, gap, reverse);
		SortWordString preproc = new SortWordString();
		preproc.init(feats_train);
		feats_train.add_preprocessor(preproc);
		feats_train.apply_preprocessor();

		StringCharFeatures charfeat_test = new StringCharFeatures(EAlphabet.DNA);
		charfeat_test.set_features(fm_test_dna);
		StringWordFeatures feats_test = new StringWordFeatures(charfeat.get_alphabet());
		feats_test.obtain_from_char(charfeat_test, order-1, order, gap, reverse);
		feats_test.add_preprocessor(preproc);
		feats_test.apply_preprocessor();

		HammingWordDistance distance = new HammingWordDistance(feats_train, feats_train, use_sign);

		double[,] dm_train = distance.get_distance_matrix();
		distance.init(feats_train, feats_test);
		double[,] dm_test = distance.get_distance_matrix();
	}
    internal static ArrayList run(IList para)
    {
        bool reverse = false;
        modshogun.init_shogun_with_defaults();

        int order = (int)((int?)para[0]);
        int gap = (int)((int?)para[1]);
        int degree = (int)((int?)para[2]);

        string[] fm_train_dna = Load.load_dna("../data/fm_train_dna.dat");
        string[] fm_test_dna = Load.load_dna("../data/fm_test_dna.dat");

        StringCharFeatures charfeat = new StringCharFeatures(fm_train_dna, DNA);
        StringWordFeatures feats_train = new StringWordFeatures(charfeat.get_alphabet());
        feats_train.obtain_from_char(charfeat, order-1, order, gap, false);

        charfeat = new StringCharFeatures(fm_test_dna, DNA);
        StringWordFeatures feats_test = new StringWordFeatures(charfeat.get_alphabet());
        feats_test.obtain_from_char(charfeat, order-1, order, gap, false);

        PolyMatchWordStringKernel kernel = new PolyMatchWordStringKernel(feats_train, feats_train, degree, true);
        DoubleMatrix km_train = kernel.get_kernel_matrix();
        kernel.init(feats_train, feats_test);
        DoubleMatrix km_test =kernel.get_kernel_matrix();

        ArrayList result = new ArrayList();
        result.Add(km_train);
        result.Add(km_test);
        result.Add(kernel);
        modshogun.exit_shogun();
        return result;
    }
    static void Main(string[] argv)
    {
        modshogun.init_shogun_with_defaults();
        int degree = 20;
        double scale = 1.4;
        int size_cache = 10;
        int order = 3;
        int gap = 0;
        bool reverse = false;

        string[] fm_train_dna = Load.load_dna("../data/fm_train_dna.dat");
        string[] fm_test_dna = Load.load_dna("../data/fm_test_dna.dat");

        StringCharFeatures charfeat = new StringCharFeatures(fm_train_dna, DNA);
        StringWordFeatures feats_train = new StringWordFeatures(DNA);
        feats_train.obtain_from_char(charfeat, order-1, order, gap, reverse);

        StringCharFeatures charfeat_test = new StringCharFeatures(fm_test_dna, DNA);
        StringWordFeatures feats_test = new StringWordFeatures(DNA);
        feats_test.obtain_from_char(charfeat_test, order-1, order, gap, reverse);

        MatchWordStringKernel kernel = new MatchWordStringKernel(size_cache, degree);
        kernel.set_normalizer(new AvgDiagKernelNormalizer(scale));
        kernel.init(feats_train, feats_train);

        DoubleMatrix km_train = kernel.get_kernel_matrix();
        kernel.init(feats_train, feats_test);
        DoubleMatrix km_test = kernel.get_kernel_matrix();
        modshogun.exit_shogun();
    }
    internal static ArrayList run(IList para)
    {
        bool reverse = false;
        modshogun.init_shogun_with_defaults();
        int order = (int)((int?)para[0]);
        int gap = (int)((int?)para[1]);

        string[] fm_train_dna = Load.load_dna("../data/fm_train_dna.dat");

        StringCharFeatures charfeat = new StringCharFeatures(fm_train_dna, DNA);
        StringWordFeatures feats = new StringWordFeatures(charfeat.get_alphabet());
        feats.obtain_from_char(charfeat, order-1, order, gap, reverse);

        Histogram histo = new Histogram(feats);
        histo.train();

        histo.get_histogram();

        int num_examples = feats.get_num_vectors();
        int num_param = histo.get_num_model_parameters();

        DoubleMatrix out_likelihood = histo.get_log_likelihood();
        double out_sample = histo.get_log_likelihood_sample();

        ArrayList result = new ArrayList();
        result.Add(histo);
        result.Add(out_sample);
        result.Add(out_likelihood);
        modshogun.exit_shogun();
        return result;
    }
    public static void Main()
    {
        modshogun.init_shogun_with_defaults();

        bool reverse = false;
        int order = 3;
        int gap = 0;
        int degree = 2;

        string[] fm_train_dna = Load.load_dna("../data/fm_train_dna.dat");
        string[] fm_test_dna = Load.load_dna("../data/fm_test_dna.dat");

        StringCharFeatures charfeat = new StringCharFeatures(fm_train_dna, EAlphabet.DNA);
        StringWordFeatures feats_train = new StringWordFeatures(charfeat.get_alphabet());
        feats_train.obtain_from_char(charfeat, order-1, order, gap, false);

        charfeat = new StringCharFeatures(fm_test_dna, EAlphabet.DNA);
        StringWordFeatures feats_test = new StringWordFeatures(charfeat.get_alphabet());
        feats_test.obtain_from_char(charfeat, order-1, order, gap, false);

        PolyMatchWordStringKernel kernel = new PolyMatchWordStringKernel(feats_train, feats_train, degree, true);
        double[,] km_train = kernel.get_kernel_matrix();
        kernel.init(feats_train, feats_test);
        double[,] km_test=kernel.get_kernel_matrix();
    }
    public static void Main()
    {
        modshogun.init_shogun_with_defaults();

        bool reverse = false;
        int order = 3;
        int gap = 0;

        String[] fm_train_dna = Load.load_dna("../data/fm_train_dna.dat");
        String[] fm_test_dna = Load.load_dna("../data/fm_test_dna.dat");

        StringCharFeatures charfeat = new StringCharFeatures(fm_train_dna, EAlphabet.DNA);
        StringWordFeatures feats_train = new StringWordFeatures(charfeat.get_alphabet());
        feats_train.obtain_from_char(charfeat, order-1, order, gap, false);

        charfeat = new StringCharFeatures(fm_test_dna, EAlphabet.DNA);
        StringWordFeatures feats_test = new StringWordFeatures(charfeat.get_alphabet());
        feats_test.obtain_from_char(charfeat, order-1, order, gap, false);

        BinaryLabels labels = new BinaryLabels(Load.load_labels("../data/label_train_dna.dat"));

        PluginEstimate pie = new PluginEstimate();
        pie.set_labels(labels);
        pie.set_features(feats_train);
        pie.train();

        SalzbergWordStringKernel kernel = new SalzbergWordStringKernel(feats_train, feats_train, pie, labels);
        double[,] km_train = kernel.get_kernel_matrix();
        kernel.init(feats_train, feats_test);
        pie.set_features(feats_test);
        BinaryLabels.obtain_from_generic(pie.apply()).get_labels();
        double[,] km_test=kernel.get_kernel_matrix();

        modshogun.exit_shogun();
    }
	public static void Main() {
		bool reverse = false;
		modshogun.init_shogun_with_defaults();
		int order = 3;
		int gap = 4;

		String[] fm_train_dna = Load.load_dna("../data/fm_train_dna.dat");

		StringCharFeatures charfeat = new StringCharFeatures(fm_train_dna, EAlphabet.DNA);
		StringWordFeatures feats = new StringWordFeatures(charfeat.get_alphabet());
		feats.obtain_from_char(charfeat, order-1, order, gap, reverse);

		LinearHMM hmm = new LinearHMM(feats);
		hmm.train();

		hmm.get_transition_probs();

		int  num_examples = feats.get_num_vectors();
		int num_param = hmm.get_num_model_parameters();
		for (int i = 0; i < num_examples; i++)
			for(int j = 0; j < num_param; j++) {
			hmm.get_log_derivative(j, i);
		}

		double[] out_likelihood = hmm.get_log_likelihood();
		double out_sample = hmm.get_log_likelihood_sample();

	}
    static void Main(string[] argv)
    {
        modshogun.init_shogun_with_defaults();
        int order = 3;
        int gap = 0;
        bool reverse = false;

        string[] fm_train_dna = Load.load_dna("../data/fm_train_dna.dat");
        string[] fm_test_dna = Load.load_dna("../data/fm_test_dna.dat");
        DoubleMatrix fm_test_real = Load.load_numbers("../data/fm_test_real.dat");

        StringCharFeatures charfeat = new StringCharFeatures(DNA);
        charfeat.set_features(fm_train_dna);
        StringWordFeatures feats_train = new StringWordFeatures(charfeat.get_alphabet());
        feats_train.obtain_from_char(charfeat, order-1, order, gap, reverse);
        SortWordString preproc = new SortWordString();
        preproc.init(feats_train);
        feats_train.add_preprocessor(preproc);
        feats_train.apply_preprocessor();

        StringCharFeatures charfeat_test = new StringCharFeatures(DNA);
        charfeat_test.set_features(fm_test_dna);
        StringWordFeatures feats_test = new StringWordFeatures(charfeat.get_alphabet());
        feats_test.obtain_from_char(charfeat_test, order-1, order, gap, reverse);
        feats_test.add_preprocessor(preproc);
        feats_test.apply_preprocessor();

        ManhattanWordDistance distance = new ManhattanWordDistance(feats_train, feats_train);

        DoubleMatrix dm_train = distance.get_distance_matrix();
        distance.init(feats_train, feats_test);
        DoubleMatrix dm_test = distance.get_distance_matrix();
        modshogun.exit_shogun();
    }
Example #11
0
    internal static ArrayList run(IList para)
    {
        bool reverse = false;
        modshogun.init_shogun_with_defaults();
        int N = (int)((int?)para[0]);
        int M = (int)((int?)para[1]);
        double pseudo = (double)((double?)para[2]);
        int order = (int)((int?)para[3]);
        int gap = (int)((int?)para[4]);

        string[] fm_train_dna = Load.load_cubes("../data/fm_train_cube.dat");

        StringCharFeatures charfeat = new StringCharFeatures(fm_train_dna, CUBE);
        StringWordFeatures feats = new StringWordFeatures(charfeat.get_alphabet());
        feats.obtain_from_char(charfeat, order-1, order, gap, reverse);

        HMM hmm = new HMM(feats, N, M, pseudo);
        hmm.train();
        hmm.baum_welch_viterbi_train(BW_NORMAL);

        int num_examples = feats.get_num_vectors();
        int num_param = hmm.get_num_model_parameters();
        for (int i = 0; i < num_examples; i++)
        {
            for(int j = 0; j < num_param; j++)
            {
            hmm.get_log_derivative(j, i);
        }
        }

        int best_path = 0;
        int best_path_state = 0;
        for(int i = 0; i < num_examples; i++)
        {
            best_path += hmm.best_path(i);
            for(int j = 0; j < N; j++)
            {
                best_path_state += hmm.get_best_path_state(i, j);
            }
        }

        DoubleMatrix lik_example = hmm.get_log_likelihood();
        double lik_sample = hmm.get_log_likelihood_sample();

        ArrayList result = new ArrayList();
        result.Add(lik_example);
        result.Add(lik_sample);
        result.Add(hmm);
        modshogun.exit_shogun();
        return result;
    }
    internal static ArrayList run(string[] strs)
    {
        modshogun.init_shogun_with_defaults();
        StringCharFeatures cf = new StringCharFeatures(strings, RAWBYTE);
        StringWordFeatures wf = new StringWordFeatures(RAWBYTE);
        wf.obtain_from_char(cf, 0, 2, 0, false);
        wf.set_feature_vector(new DoubleMatrix(new double[][] {{1,2,3,4,5}}), 0);

        ArrayList result = new ArrayList();
        //result.add(wf.get_features());
        result.Add(wf);

        modshogun.exit_shogun();
        return result;
    }
    public static void Main()
    {
        modshogun.init_shogun_with_defaults();
        int  order   = 3;
        int  gap     = 0;
        bool reverse = false;

        String[] fm_train_dna = Load.load_dna("../data/fm_train_dna.dat");
        String[] fm_test_dna  = Load.load_dna("../data/fm_test_dna.dat");
        double[,] fm_test_real = Load.load_numbers("../data/fm_test_real.dat");

        StringCharFeatures charfeat = new StringCharFeatures(EAlphabet.DNA);

        charfeat.set_features(fm_train_dna);
        StringWordFeatures feats_train = new StringWordFeatures(charfeat.get_alphabet());

        feats_train.obtain_from_char(charfeat, order - 1, order, gap, reverse);
        SortWordString preproc = new SortWordString();

        preproc.init(feats_train);
        feats_train.add_preprocessor(preproc);
        feats_train.apply_preprocessor();

        StringCharFeatures charfeat_test = new StringCharFeatures(EAlphabet.DNA);

        charfeat_test.set_features(fm_test_dna);
        StringWordFeatures feats_test = new StringWordFeatures(charfeat.get_alphabet());

        feats_test.obtain_from_char(charfeat_test, order - 1, order, gap, reverse);
        feats_test.add_preprocessor(preproc);
        feats_test.apply_preprocessor();

        ManhattanWordDistance distance = new ManhattanWordDistance(feats_train, feats_train);

        double[,] dm_train = distance.get_distance_matrix();
        distance.init(feats_train, feats_test);
        double[,] dm_test = distance.get_distance_matrix();

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

        foreach (double item in dm_test)
        {
            Console.Write(item);
        }
    }
    public static void Main()
    {
        bool reverse = false;
        modshogun.init_shogun_with_defaults();
        int N = 1;
        int M = 512;
        double pseudo = 1e-5;
        int order = 3;
        int gap = 0;

        string[] fm_train_dna = Load.load_cubes("../data/fm_train_cube.dat");

        StringCharFeatures charfeat = new StringCharFeatures(fm_train_dna, EAlphabet.CUBE);
        StringWordFeatures feats = new StringWordFeatures(charfeat.get_alphabet());
        feats.obtain_from_char(charfeat, order-1, order, gap, reverse);

        HMM hmm = new HMM(feats, N, M, pseudo);
        hmm.train();
        hmm.baum_welch_viterbi_train(BaumWelchViterbiType.BW_NORMAL);

        int  num_examples = feats.get_num_vectors();
        int num_param = hmm.get_num_model_parameters();
        for (int i = 0; i < num_examples; i++)
            for(int j = 0; j < num_param; j++) {
            hmm.get_log_derivative(j, i);
        }

        int best_path = 0;
        int best_path_state = 0;
        for(int i = 0; i < num_examples; i++){
            best_path += (int)hmm.best_path(i);
            for(int j = 0; j < N; j++)
                best_path_state += hmm.get_best_path_state(i, j);
        }

        double[] lik_example = hmm.get_log_likelihood();
        double lik_sample = hmm.get_log_likelihood_sample();

        modshogun.exit_shogun();
    }
    internal static ArrayList run(IList para)
    {
        bool reverse = false;
        modshogun.init_shogun_with_defaults();

        int order = (int)((int?)para[0]);
        int gap = (int)((int?)para[1]);

        string[] fm_train_dna = Load.load_dna("../data/fm_train_dna.dat");
        string[] fm_test_dna = Load.load_dna("../data/fm_test_dna.dat");

        StringCharFeatures charfeat = new StringCharFeatures(fm_train_dna, DNA);
        StringWordFeatures feats_train = new StringWordFeatures(charfeat.get_alphabet());
        feats_train.obtain_from_char(charfeat, order-1, order, gap, false);

        charfeat = new StringCharFeatures(fm_test_dna, DNA);
        StringWordFeatures feats_test = new StringWordFeatures(charfeat.get_alphabet());
        feats_test.obtain_from_char(charfeat, order-1, order, gap, false);

        Labels labels = new Labels(Load.load_labels("../data/label_train_dna.dat"));

        PluginEstimate pie = new PluginEstimate();
        pie.set_labels(labels);
        pie.set_features(feats_train);
        pie.train();

        SalzbergWordStringKernel kernel = new SalzbergWordStringKernel(feats_train, feats_train, pie, labels);
        DoubleMatrix km_train = kernel.get_kernel_matrix();
        kernel.init(feats_train, feats_test);
        pie.set_features(feats_test);
        pie.apply().get_labels();
        DoubleMatrix km_test =kernel.get_kernel_matrix();

        ArrayList result = new ArrayList();
        result.Add(km_train);
        result.Add(km_test);
        result.Add(kernel);
        modshogun.exit_shogun();
        return result;
    }
Example #16
0
    public static void Main()
    {
        modshogun.init_shogun_with_defaults();

        bool reverse = false;
        int  order   = 3;
        int  gap     = 0;

        String[] fm_train_dna = Load.load_dna("../data/fm_train_dna.dat");
        String[] fm_test_dna  = Load.load_dna("../data/fm_test_dna.dat");

        StringCharFeatures charfeat    = new StringCharFeatures(fm_train_dna, EAlphabet.DNA);
        StringWordFeatures feats_train = new StringWordFeatures(charfeat.get_alphabet());

        feats_train.obtain_from_char(charfeat, order - 1, order, gap, false);

        charfeat = new StringCharFeatures(fm_test_dna, EAlphabet.DNA);
        StringWordFeatures feats_test = new StringWordFeatures(charfeat.get_alphabet());

        feats_test.obtain_from_char(charfeat, order - 1, order, gap, false);

        BinaryLabels labels = new BinaryLabels(Load.load_labels("../data/label_train_dna.dat"));

        PluginEstimate pie = new PluginEstimate();

        pie.set_labels(labels);
        pie.set_features(feats_train);
        pie.train();

        SalzbergWordStringKernel kernel = new SalzbergWordStringKernel(feats_train, feats_train, pie, labels);

        double[,] km_train = kernel.get_kernel_matrix();
        kernel.init(feats_train, feats_test);
        pie.set_features(feats_test);
        BinaryLabels.obtain_from_generic(pie.apply()).get_labels();
        double[,] km_test = kernel.get_kernel_matrix();

        modshogun.exit_shogun();
    }
Example #17
0
    internal static void run(IList para)
    {
        bool reverse = false;
        modshogun.init_shogun_with_defaults();
        int order = (int)((int?)para[0]);
        int gap = (int)((int?)para[1]);

        string[] fm_train_dna = Load.load_dna("../data/fm_train_dna.dat");

        StringCharFeatures charfeat = new StringCharFeatures(fm_train_dna, DNA);
        StringWordFeatures feats = new StringWordFeatures(charfeat.get_alphabet());
        feats.obtain_from_char(charfeat, order-1, order, gap, reverse);

        PositionalPWM ppwm = new PositionalPWM();
        ppwm.set_sigma(5.0);
        ppwm.set_mean(10.0);
        DoubleMatrix pwm = new DoubleMatrix(new double[][] {{0.0, 0.5, 0.1, 1.0}, {0.0, 0.5, 0.5, 0.0}, {1.0, 0.0, 0.4, 0.0}, {0.0, 0.0, 0.0, 0.0}});
        //ppwm.set_pwm(DoubleMatrix.log(pwm));
        ppwm.compute_w(20);
        DoubleMatrix w = ppwm.get_w();
        modshogun.exit_shogun();
    }
    internal static ArrayList run(IList para)
    {
        bool reverse = false;
        modshogun.init_shogun_with_defaults();
        int order = (int)((int?)para[0]);
        int gap = (int)((int?)para[1]);

        string[] fm_train_dna = Load.load_dna("../data/fm_train_dna.dat");

        StringCharFeatures charfeat = new StringCharFeatures(fm_train_dna, DNA);
        StringWordFeatures feats = new StringWordFeatures(charfeat.get_alphabet());
        feats.obtain_from_char(charfeat, order-1, order, gap, reverse);

        LinearHMM hmm = new LinearHMM(feats);
        hmm.train();

        hmm.get_transition_probs();

        int num_examples = feats.get_num_vectors();
        int num_param = hmm.get_num_model_parameters();
        for (int i = 0; i < num_examples; i++)
        {
            for(int j = 0; j < num_param; j++)
            {
            hmm.get_log_derivative(j, i);
        }
        }

        DoubleMatrix out_likelihood = hmm.get_log_likelihood();
        double out_sample = hmm.get_log_likelihood_sample();

        ArrayList result = new ArrayList();
        result.Add(hmm);
        result.Add(out_sample);
        result.Add(out_likelihood);
        modshogun.exit_shogun();
        return result;
    }
    public static void Main()
    {
        bool reverse = false;

        modshogun.init_shogun_with_defaults();
        int order = 3;
        int gap   = 4;

        String[] fm_train_dna = Load.load_dna("../data/fm_train_dna.dat");

        StringCharFeatures charfeat = new StringCharFeatures(fm_train_dna, EAlphabet.DNA);
        StringWordFeatures feats    = new StringWordFeatures(charfeat.get_alphabet());

        feats.obtain_from_char(charfeat, order - 1, order, gap, reverse);

        LinearHMM hmm = new LinearHMM(feats);

        hmm.train();

        hmm.get_transition_probs();

        int num_examples = feats.get_num_vectors();
        int num_param    = hmm.get_num_model_parameters();

        for (int i = 0; i < num_examples; i++)
        {
            for (int j = 0; j < num_param; j++)
            {
                hmm.get_log_derivative(j, i);
            }
        }

        double[] out_likelihood = hmm.get_log_likelihood();
        double   out_sample     = hmm.get_log_likelihood_sample();

        modshogun.exit_shogun();
    }
    public static void Main()
    {
        modshogun.init_shogun_with_defaults();
        bool reverse = false;
        int  order   = 3;
        int  gap     = 0;

        string[] fm_train_dna = Load.load_dna("../data/fm_train_dna.dat");
        string[] fm_test_dna  = Load.load_dna("../data/fm_test_dna.dat");

        StringCharFeatures charfeat    = new StringCharFeatures(fm_train_dna, EAlphabet.DNA);
        StringWordFeatures feats_train = new StringWordFeatures(charfeat.get_alphabet());

        feats_train.obtain_from_char(charfeat, order - 1, order, gap, reverse);

        charfeat = new StringCharFeatures(fm_test_dna, EAlphabet.DNA);
        StringWordFeatures feats_test = new StringWordFeatures(charfeat.get_alphabet());

        feats_test.obtain_from_char(charfeat, order - 1, order, gap, reverse);

        SortWordString preproc = new SortWordString();

        preproc.init(feats_train);
        feats_train.add_preprocessor(preproc);
        feats_train.apply_preprocessor();
        feats_test.add_preprocessor(preproc);
        feats_test.apply_preprocessor();

        CommWordStringKernel kernel = new CommWordStringKernel(feats_train, feats_train, false);

        double[,] km_train = kernel.get_kernel_matrix();
        kernel.init(feats_train, feats_test);
        double[,] km_test = kernel.get_kernel_matrix();

        modshogun.exit_shogun();
    }
Example #21
0
 public ManhattanWordDistance(StringWordFeatures l, StringWordFeatures r) : this(modshogunPINVOKE.new_ManhattanWordDistance__SWIG_1(StringWordFeatures.getCPtr(l), StringWordFeatures.getCPtr(r)), true)
 {
     if (modshogunPINVOKE.SWIGPendingException.Pending)
     {
         throw modshogunPINVOKE.SWIGPendingException.Retrieve();
     }
 }
 public ImplicitWeightedSpecFeatures(StringWordFeatures str, bool normalize) : this(modshogunPINVOKE.new_ImplicitWeightedSpecFeatures__SWIG_1(StringWordFeatures.getCPtr(str), normalize), true)
 {
     if (modshogunPINVOKE.SWIGPendingException.Pending)
     {
         throw modshogunPINVOKE.SWIGPendingException.Retrieve();
     }
 }
 public MatchWordStringKernel(StringWordFeatures l, StringWordFeatures r, int degree) : this(modshogunPINVOKE.new_MatchWordStringKernel__SWIG_2(StringWordFeatures.getCPtr(l), StringWordFeatures.getCPtr(r), degree), true) {
   if (modshogunPINVOKE.SWIGPendingException.Pending) throw modshogunPINVOKE.SWIGPendingException.Retrieve();
 }
 public SalzbergWordStringKernel(StringWordFeatures l, StringWordFeatures r, PluginEstimate pie, Labels labels) : this(modshogunPINVOKE.new_SalzbergWordStringKernel__SWIG_3(StringWordFeatures.getCPtr(l), StringWordFeatures.getCPtr(r), PluginEstimate.getCPtr(pie), Labels.getCPtr(labels)), true) {
   if (modshogunPINVOKE.SWIGPendingException.Pending) throw modshogunPINVOKE.SWIGPendingException.Retrieve();
 }
Example #25
0
 public void set_observation_nocache(StringWordFeatures obs) {
   modshogunPINVOKE.HMM_set_observation_nocache(swigCPtr, StringWordFeatures.getCPtr(obs));
   if (modshogunPINVOKE.SWIGPendingException.Pending) throw modshogunPINVOKE.SWIGPendingException.Retrieve();
 }
Example #26
0
 public bool append_features(StringWordFeatures sf) {
   bool ret = modshogunPINVOKE.StringWordFeatures_append_features(swigCPtr, StringWordFeatures.getCPtr(sf));
   if (modshogunPINVOKE.SWIGPendingException.Pending) throw modshogunPINVOKE.SWIGPendingException.Retrieve();
   return ret;
 }
Example #27
0
 public virtual void set_features(StringWordFeatures feat) {
   modshogunPINVOKE.PluginEstimate_set_features(swigCPtr, StringWordFeatures.getCPtr(feat));
   if (modshogunPINVOKE.SWIGPendingException.Pending) throw modshogunPINVOKE.SWIGPendingException.Retrieve();
 }
 public CanberraWordDistance(StringWordFeatures l, StringWordFeatures r) : this(modshogunPINVOKE.new_CanberraWordDistance__SWIG_1(StringWordFeatures.getCPtr(l), StringWordFeatures.getCPtr(r)), true) {
   if (modshogunPINVOKE.SWIGPendingException.Pending) throw modshogunPINVOKE.SWIGPendingException.Retrieve();
 }
Example #29
0
 public HammingWordDistance(StringWordFeatures l, StringWordFeatures r, bool use_sign) : this(modshogunPINVOKE.new_HammingWordDistance__SWIG_2(StringWordFeatures.getCPtr(l), StringWordFeatures.getCPtr(r), use_sign), true)
 {
     if (modshogunPINVOKE.SWIGPendingException.Pending)
     {
         throw modshogunPINVOKE.SWIGPendingException.Retrieve();
     }
 }
 public ExplicitSpecFeatures(StringWordFeatures str) : this(modshogunPINVOKE.new_ExplicitSpecFeatures__SWIG_2(StringWordFeatures.getCPtr(str)), true) {
   if (modshogunPINVOKE.SWIGPendingException.Pending) throw modshogunPINVOKE.SWIGPendingException.Retrieve();
 }
Example #31
0
 public StringWordFeatures(StringWordFeatures orig) : this(modshogunPINVOKE.new_StringWordFeatures__SWIG_5(StringWordFeatures.getCPtr(orig)), true) {
   if (modshogunPINVOKE.SWIGPendingException.Pending) throw modshogunPINVOKE.SWIGPendingException.Retrieve();
 }
Example #32
0
 public LinearHMM(StringWordFeatures f) : this(modshogunPINVOKE.new_LinearHMM__SWIG_1(StringWordFeatures.getCPtr(f)), true) {
   if (modshogunPINVOKE.SWIGPendingException.Pending) throw modshogunPINVOKE.SWIGPendingException.Retrieve();
 }
Example #33
0
 public HMM(StringWordFeatures obs, int N, int M, double PSEUDO) : this(modshogunPINVOKE.new_HMM__SWIG_2(StringWordFeatures.getCPtr(obs), N, M, PSEUDO), true) {
   if (modshogunPINVOKE.SWIGPendingException.Pending) throw modshogunPINVOKE.SWIGPendingException.Retrieve();
 }
Example #34
0
 internal static HandleRef getCPtr(StringWordFeatures obj)
 {
     return((obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr);
 }
Example #35
0
 public Histogram(StringWordFeatures f) : this(modshogunPINVOKE.new_Histogram__SWIG_1(StringWordFeatures.getCPtr(f)), true) {
   if (modshogunPINVOKE.SWIGPendingException.Pending) throw modshogunPINVOKE.SWIGPendingException.Retrieve();
 }
Example #36
0
 public StringWordFeatures(StringWordFeatures orig) : this(modshogunPINVOKE.new_StringWordFeatures__SWIG_5(StringWordFeatures.getCPtr(orig)), true)
 {
     if (modshogunPINVOKE.SWIGPendingException.Pending)
     {
         throw modshogunPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Example #37
0
 public PolyMatchWordStringKernel(StringWordFeatures l, StringWordFeatures r, int degree, bool inhomogene) : this(modshogunPINVOKE.new_PolyMatchWordStringKernel__SWIG_2(StringWordFeatures.getCPtr(l), StringWordFeatures.getCPtr(r), degree, inhomogene), true)
 {
     if (modshogunPINVOKE.SWIGPendingException.Pending)
     {
         throw modshogunPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Example #38
0
 public Histogram(StringWordFeatures f) : this(modshogunPINVOKE.new_Histogram__SWIG_1(StringWordFeatures.getCPtr(f)), true)
 {
     if (modshogunPINVOKE.SWIGPendingException.Pending)
     {
         throw modshogunPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Example #39
0
 public void set_observations(StringWordFeatures obs, HMM hmm) {
   modshogunPINVOKE.HMM_set_observations__SWIG_0(swigCPtr, StringWordFeatures.getCPtr(obs), HMM.getCPtr(hmm));
   if (modshogunPINVOKE.SWIGPendingException.Pending) throw modshogunPINVOKE.SWIGPendingException.Retrieve();
 }
Example #40
0
 public HMM(StringWordFeatures obs, int N, int M, double PSEUDO) : this(modshogunPINVOKE.new_HMM__SWIG_2(StringWordFeatures.getCPtr(obs), N, M, PSEUDO), true)
 {
     if (modshogunPINVOKE.SWIGPendingException.Pending)
     {
         throw modshogunPINVOKE.SWIGPendingException.Retrieve();
     }
 }
 public ExplicitSpecFeatures(StringWordFeatures str) : this(modshogunPINVOKE.new_ExplicitSpecFeatures__SWIG_2(StringWordFeatures.getCPtr(str)), true)
 {
     if (modshogunPINVOKE.SWIGPendingException.Pending)
     {
         throw modshogunPINVOKE.SWIGPendingException.Retrieve();
     }
 }
 public HistogramWordStringKernel(StringWordFeatures l, StringWordFeatures r, PluginEstimate pie) : this(modshogunPINVOKE.new_HistogramWordStringKernel__SWIG_2(StringWordFeatures.getCPtr(l), StringWordFeatures.getCPtr(r), PluginEstimate.getCPtr(pie)), true) {
   if (modshogunPINVOKE.SWIGPendingException.Pending) throw modshogunPINVOKE.SWIGPendingException.Retrieve();
 }
 public WeightedCommWordStringKernel(StringWordFeatures l, StringWordFeatures r) : this(modshogunPINVOKE.new_WeightedCommWordStringKernel__SWIG_4(StringWordFeatures.getCPtr(l), StringWordFeatures.getCPtr(r)), true)
 {
     if (modshogunPINVOKE.SWIGPendingException.Pending)
     {
         throw modshogunPINVOKE.SWIGPendingException.Retrieve();
     }
 }
    static void Main(string[] argv)
    {
        modshogun.init_shogun_with_defaults();
        int num = 10;
        int order = 7;
        int gap = 0;
        bool reverse = false;

        string[] POS = new string[141];
        for (int i = 0; i < 60; i++)
        {
            POS[i] = repeat("ACGT", 10);
        }
        for (int i = 61; i < 82; i++)
        {
            POS[i] = repeat("TTGT", 10);
        }
        for (int i = 83; i < 141; i++)
        {
            POS[i] = repeat("ACGT", 10);
        }

        string[] NEG = new string[141];
        for (int i = 0; i < 60; i++)
        {
            NEG[i] = repeat("ACGT", 10);
        }
        for (int i = 61; i < 82; i++)
        {
            NEG[i] = repeat("TTGT", 10);
        }
        for (int i = 83; i < 141; i++)
        {
            NEG[i] = repeat("ACGT", 10);
        }

        string[] POSNEG = new string[282];
        for (int i = 0; i < 141; i++)
        {
            POSNEG[i] = POS[i];
            POSNEG[i + 141] = NEG[i];
        }

        for(int i = 0; i < 10; i++)
        {
            Alphabet alpha = new Alphabet(DNA);
            StringCharFeatures traindat = new StringCharFeatures(alpha);
            traindat.set_features(POSNEG);
            StringWordFeatures trainudat = new StringWordFeatures(traindat.get_alphabet());
            trainudat.obtain_from_char(traindat, order-1, order, gap, reverse);
            SortWordString pre = new SortWordString();
            pre.init(trainudat);
            trainudat.add_preprocessor(pre);
            trainudat.apply_preprocessor();
            CommWordStringKernel spec = new CommWordStringKernel(10, false);
            spec.set_normalizer(new IdentityKernelNormalizer());
            spec.init(trainudat, trainudat);
            DoubleMatrix K = spec.get_kernel_matrix();
        }

        modshogun.exit_shogun();
    }
 public WeightedCommWordStringKernel(StringWordFeatures l, StringWordFeatures r, bool use_sign, int size) : this(modshogunPINVOKE.new_WeightedCommWordStringKernel__SWIG_2(StringWordFeatures.getCPtr(l), StringWordFeatures.getCPtr(r), use_sign, size), true)
 {
     if (modshogunPINVOKE.SWIGPendingException.Pending)
     {
         throw modshogunPINVOKE.SWIGPendingException.Retrieve();
     }
 }
 public SalzbergWordStringKernel(StringWordFeatures l, StringWordFeatures r, PluginEstimate pie) : this(modshogunPINVOKE.new_SalzbergWordStringKernel__SWIG_4(StringWordFeatures.getCPtr(l), StringWordFeatures.getCPtr(r), PluginEstimate.getCPtr(pie)), true)
 {
     if (modshogunPINVOKE.SWIGPendingException.Pending)
     {
         throw modshogunPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Example #47
0
 internal static HandleRef getCPtr(StringWordFeatures obj) {
   return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
 }