Ejemplo n.º 1
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, 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();
    }
	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();
	}
    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, reverse);

        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, 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);

        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 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();
    }
Ejemplo n.º 5
0
 internal static HandleRef getCPtr(CommWordStringKernel obj) {
   return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
 }
Ejemplo n.º 6
0
 internal static HandleRef getCPtr(CommWordStringKernel obj)
 {
     return((obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr);
 }