예제 #1
0
    static void Main(string[] argv)
    {
        modshogun.init_shogun_with_defaults();
        double width = 1.2;

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

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

        GaussianKernel kernel = new GaussianKernel(feats_train, feats_test, width);
        DoubleMatrix km_train = kernel.get_kernel_matrix();
        AsciiFile f =new AsciiFile("gaussian_train.ascii",'w');
        kernel.save(f);

        kernel.init(feats_train, feats_test);
        DoubleMatrix km_test = kernel.get_kernel_matrix();
        AsciiFile f_test =new AsciiFile("gaussian_train.ascii",'w');
        kernel.save(f_test);

        Console.WriteLine(km_train.ToString());
        Console.WriteLine(km_test.ToString());

        modshogun.exit_shogun();
    }
예제 #2
0
    public static void Main()
    {
        modshogun.init_shogun_with_defaults();
        double width = 1.2;

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

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

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

        double[,] km_train = kernel.get_kernel_matrix();
        AsciiFile f = new AsciiFile("gaussian_train.ascii", 'w');

        kernel.save(f);

        kernel.init(feats_train, feats_test);
        double[,] km_test = kernel.get_kernel_matrix();
        AsciiFile f_test = new AsciiFile("gaussian_train.ascii", 'w');

        kernel.save(f_test);

        //  Parse and Display km_train
        Console.Write("km_train:\n");
        int numRows = km_train.GetLength(0);
        int numCols = km_train.GetLength(1);

        for (int i = 0; i < numRows; i++)
        {
            for (int j = 0; j < numCols; j++)
            {
                Console.Write(km_train[i, j] + " ");
            }
            Console.Write("\n");
        }

        //  Parse and Display km_test
        Console.Write("\nkm_test:\n");
        numRows = km_test.GetLength(0);
        numCols = km_test.GetLength(1);

        for (int i = 0; i < numRows; i++)
        {
            for (int j = 0; j < numCols; j++)
            {
                Console.Write(km_test[i, j] + " ");
            }
            Console.Write("\n");
        }

        modshogun.exit_shogun();
    }
예제 #3
0
    internal static ArrayList run(string filename)
    {
        modshogun.init_shogun_with_defaults();
        StringCharFeatures f = new StringCharFeatures(RAWBYTE);
        f.load_from_directory(".");

        AsciiFile fil = new AsciiFile(fname);
        f.load(fil);

        ArrayList result = new ArrayList();
        result.Add(f.get_features());
        result.Add(f);

        modshogun.exit_shogun();
        return result;
    }
    public static void Main()
    {
        modshogun.init_shogun_with_defaults();
        double width = 1.2;

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

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

        GaussianKernel kernel = new GaussianKernel(feats_train, feats_test, width);
        double[,] km_train = kernel.get_kernel_matrix();
        AsciiFile f=new AsciiFile("gaussian_train.ascii",'w');
        kernel.save(f);

        kernel.init(feats_train, feats_test);
        double[,] km_test = kernel.get_kernel_matrix();
        AsciiFile f_test=new AsciiFile("gaussian_train.ascii",'w');
        kernel.save(f_test);

        //  Parse and Display km_train
        Console.Write("km_train:\n");
        int numRows = km_train.GetLength(0);
        int numCols = km_train.GetLength(1);

        for(int i = 0; i < numRows; i++){
            for(int j = 0; j < numCols; j++){
                Console.Write(km_train[i,j] +" ");
            }
            Console.Write("\n");
        }

        //  Parse and Display km_test
        Console.Write("\nkm_test:\n");
        numRows = km_test.GetLength(0);
        numCols = km_test.GetLength(1);

        for(int i = 0; i < numRows; i++){
            for(int j = 0; j < numCols; j++){
                Console.Write(km_test[i,j] +" ");
            }
            Console.Write("\n");
        }

        modshogun.exit_shogun();
    }
예제 #5
0
 internal static HandleRef getCPtr(AsciiFile obj) {
   return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
 }
예제 #6
0
 internal static HandleRef getCPtr(AsciiFile obj)
 {
     return((obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr);
 }