public StringUlongFeatures(StringUlongFeatures orig) : this(modshogunPINVOKE.new_StringUlongFeatures__SWIG_5(StringUlongFeatures.getCPtr(orig)), true)
 {
     if (modshogunPINVOKE.SWIGPendingException.Pending)
     {
         throw modshogunPINVOKE.SWIGPendingException.Retrieve();
     }
 }
	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);
		StringUlongFeatures feats_train = new StringUlongFeatures(charfeat.get_alphabet());
		feats_train.obtain_from_char(charfeat, order-1, order, gap, reverse);

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

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

		CommUlongStringKernel kernel = new CommUlongStringKernel(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();
	}
Exemple #3
0
 public CommUlongStringKernel(StringUlongFeatures l, StringUlongFeatures r) : this(modshogunPINVOKE.new_CommUlongStringKernel__SWIG_5(StringUlongFeatures.getCPtr(l), StringUlongFeatures.getCPtr(r)), true)
 {
     if (modshogunPINVOKE.SWIGPendingException.Pending)
     {
         throw modshogunPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Exemple #4
0
 public CommUlongStringKernel(StringUlongFeatures l, StringUlongFeatures r, bool use_sign, int size) : this(modshogunPINVOKE.new_CommUlongStringKernel__SWIG_3(StringUlongFeatures.getCPtr(l), StringUlongFeatures.getCPtr(r), use_sign, size), true)
 {
     if (modshogunPINVOKE.SWIGPendingException.Pending)
     {
         throw modshogunPINVOKE.SWIGPendingException.Retrieve();
     }
 }
    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);
        StringUlongFeatures feats_train = new StringUlongFeatures(charfeat.get_alphabet());

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

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

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

        SortUlongString preproc = new SortUlongString();

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

        CommUlongStringKernel kernel = new CommUlongStringKernel(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 bool append_features(StringUlongFeatures sf)
    {
        bool ret = modshogunPINVOKE.StringUlongFeatures_append_features(swigCPtr, StringUlongFeatures.getCPtr(sf));

        if (modshogunPINVOKE.SWIGPendingException.Pending)
        {
            throw modshogunPINVOKE.SWIGPendingException.Retrieve();
        }
        return(ret);
    }
    public StringUlongFeatures get_transposed()
    {
        IntPtr cPtr             = modshogunPINVOKE.StringUlongFeatures_get_transposed(swigCPtr);
        StringUlongFeatures ret = (cPtr == IntPtr.Zero) ? null : new StringUlongFeatures(cPtr, true);

        if (modshogunPINVOKE.SWIGPendingException.Pending)
        {
            throw modshogunPINVOKE.SWIGPendingException.Retrieve();
        }
        return(ret);
    }
    internal static ArrayList run(IList para)
    {
        modshogun.init_shogun_with_defaults();
        bool rev = false;
        int start = (int)((int?)para[0]);
        int order = (int)((int?)para[1]);
        int gap = (int)((int?)para[2]);
        StringCharFeatures cf = new StringCharFeatures(new string[] { "hey", "guys", "string"}, RAWBYTE);
        StringUlongFeatures uf = new StringUlongFeatures(RAWBYTE);

        uf.obtain_from_char(cf, start,order,gap,rev);
        uf.set_feature_vector(new DoubleMatrix(new double[][] {{1,2,3,4,5}}), 0);

        ArrayList result = new ArrayList();
        result.Add(uf.get_features());
        result.Add(uf.get_feature_vector(2));
        result.Add(uf.get_num_vectors());

        modshogun.exit_shogun();
        return result;
    }
    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);
        StringUlongFeatures feats_train = new StringUlongFeatures(charfeat.get_alphabet());
        feats_train.obtain_from_char(charfeat, order-1, order, gap, reverse);

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

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

        CommUlongStringKernel kernel = new CommUlongStringKernel(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;
    }
 internal static HandleRef getCPtr(StringUlongFeatures obj)
 {
     return((obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr);
 }
 public CommUlongStringKernel(StringUlongFeatures l, StringUlongFeatures r) : this(modshogunPINVOKE.new_CommUlongStringKernel__SWIG_5(StringUlongFeatures.getCPtr(l), StringUlongFeatures.getCPtr(r)), true) {
   if (modshogunPINVOKE.SWIGPendingException.Pending) throw modshogunPINVOKE.SWIGPendingException.Retrieve();
 }
 public CommUlongStringKernel(StringUlongFeatures l, StringUlongFeatures r, bool use_sign, int size) : this(modshogunPINVOKE.new_CommUlongStringKernel__SWIG_3(StringUlongFeatures.getCPtr(l), StringUlongFeatures.getCPtr(r), use_sign, size), true) {
   if (modshogunPINVOKE.SWIGPendingException.Pending) throw modshogunPINVOKE.SWIGPendingException.Retrieve();
 }
 public StringUlongFeatures(StringUlongFeatures orig) : this(modshogunPINVOKE.new_StringUlongFeatures__SWIG_5(StringUlongFeatures.getCPtr(orig)), true) {
   if (modshogunPINVOKE.SWIGPendingException.Pending) throw modshogunPINVOKE.SWIGPendingException.Retrieve();
 }
 public bool append_features(StringUlongFeatures sf) {
   bool ret = modshogunPINVOKE.StringUlongFeatures_append_features(swigCPtr, StringUlongFeatures.getCPtr(sf));
   if (modshogunPINVOKE.SWIGPendingException.Pending) throw modshogunPINVOKE.SWIGPendingException.Retrieve();
   return ret;
 }
 internal static HandleRef getCPtr(StringUlongFeatures obj) {
   return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
 }