Esempio n. 1
0
        public static SVMProblem Convert(svm_problem x)
        {
            double[] y_array = new double[x.l];
            Marshal.Copy(x.y, y_array, 0, y_array.Length);

            List <SVMNode[]> x_array = new List <SVMNode[]>();
            IntPtr           i_ptr_x = x.x;

            for (int i = 0; i < x.l; i++)
            {
                IntPtr    ptr_nodes = (IntPtr)Marshal.PtrToStructure(i_ptr_x, typeof(IntPtr));
                SVMNode[] nodes     = SVMNode.Convert(ptr_nodes);
                x_array.Add(nodes);
                i_ptr_x = IntPtr.Add(i_ptr_x, Marshal.SizeOf(typeof(IntPtr)));
            }

            SVMProblem y = new SVMProblem();

            for (int i = 0; i < x.l; i++)
            {
                y.Add(x_array[i], y_array[i]);
            }

            return(y);
        }
Esempio n. 2
0
 public OneClassClassifier(List<SVMNode[]> trainingData)
 {
     SVMProblem problem = new SVMProblem();
     for (int i = 0; i < trainingData.Count; i++)
     {
         problem.Add(trainingData[i], 1);
     }
     _trainingData = problem;
 }
Esempio n. 3
0
 public SVMProblem Clone()
 {
     SVMProblem y = new SVMProblem();
     for (int i = 0; i < Length; i++)
     {
         SVMNode[] nodes = X[i].Select(x => x.Clone()).ToArray();
         y.Add(nodes, Y[i]);
     }
     return y;
 }
Esempio n. 4
0
        public SVMProblem Clone()
        {
            SVMProblem y = new SVMProblem();

            for (int i = 0; i < Length; i++)
            {
                SVMNode[] nodes = X[i].Select(x => x.Clone()).ToArray();
                y.Add(nodes, Y[i]);
            }
            return(y);
        }
Esempio n. 5
0
        public static SVMProblem Convert(svm_problem x)
        {
            double[] y_array = new double[x.l];
            Marshal.Copy(x.y, y_array, 0, y_array.Length);

            List<SVMNode[]> x_array = new List<SVMNode[]>();
            IntPtr i_ptr_x = x.x;
            for (int i = 0; i < x.l; i++)
            {
                IntPtr ptr_nodes = (IntPtr)Marshal.PtrToStructure(i_ptr_x, typeof(IntPtr));
                SVMNode[] nodes = SVMNode.Convert(ptr_nodes);
                x_array.Add(nodes);
                i_ptr_x = IntPtr.Add(i_ptr_x, Marshal.SizeOf(typeof(IntPtr)));
            }

            SVMProblem y = new SVMProblem();
            for (int i = 0; i < x.l; i++)
            {
                y.Add(x_array[i], y_array[i]);
            }

            return y;
        }