public static double[] TestSVM(double [] test_case)
        {
            double[,] matrix = new double[5, 2];
            matrix[0, 0]     = 1;
            matrix[0, 1]     = 1;

            matrix[1, 0] = 1;
            matrix[1, 1] = 0;

            matrix[2, 0] = 0;
            matrix[2, 1] = 1;

            matrix[3, 0] = 0;
            matrix[3, 1] = 0;

            matrix[4, 0] = 10;
            matrix[4, 1] = 10;
            int[] labels = new int[] { 0, 1, 1, 0, 2 };
            IDataSet <double, int> training_set = null;// new DataSet<double, int>(ToolsCollection.ConvertToArrayArray(matrix), DataLevel.NOMINAL, labels);



            IModelLikelihood <double, int> model = new TemplateModelLibSVMCSVC().GenerateModelLikelihood(training_set);


            //double C = 200;
            //double gamma = 0.8;

            return(model.GetLikelihoods(test_case));
        }
Beispiel #2
0
        public double[] GetLikelihoods(double[] instance_features)
        {
            svm_node[] testnode = TemplateModelLibSVMCSVC.CreateNodeArray(instance_features);

            //This works correctly:
            Dictionary <int, double> prediction = svm.PredictProbabilities(testnode);

            int[] labels = prediction.Keys.ToArray();
            return(ToolsCollection.GetValueArray(prediction, labels));
        }
Beispiel #3
0
 public override int GetLabel(double[] instance_features)
 {
     svm_node[] testnode = TemplateModelLibSVMCSVC.CreateNodeArray(instance_features);
     return((int)svm.Predict(testnode));
 }