2014-11-07 6 views
1

Я скопировал этот код из онлайн-документации accord.net. Он почему-то не работает. http://accord-ramework.net/docs/html/T_Accord_MachineLearning_VectorMachines_SupportVectorMachine.htmaccord.net функция вычисления для svm не работает

using System; 
using System.Windows; 
using Accord.Controls; 
using Accord.MachineLearning.VectorMachines; 
using Accord.MachineLearning.VectorMachines.Learning; 
using Accord.Math; 
using Accord.Statistics.Kernels; 
namespace accord 
{ 
class Program 
{ 
    [MTAThread] 
    static void Main(string[] args) 
    { 
     // Example AND problem 
     double[][] inputs = 
     { 
      new double[] { 0, 0 }, // 0 and 0: 0 (label -1) 
      new double[] { 0, 1 }, // 0 and 1: 0 (label -1) 
      new double[] { 1, 0 }, // 1 and 0: 0 (label -1) 
      new double[] { 1, 1 } // 1 and 1: 1 (label +1) 
     }; 

     // Dichotomy SVM outputs should be given as [-1;+1] 
     int[] labels = 
    { 
     // 0, 0, 0, 1 
      -1, -1, -1, 1 
    }; 

     // Create a Support Vector Machine for the given inputs 
     SupportVectorMachine machine = new SupportVectorMachine(inputs[0].Length); 

     // Instantiate a new learning algorithm for SVMs 
     SequentialMinimalOptimization smo = new SequentialMinimalOptimization(machine, inputs, labels); 

     // Set up the learning algorithm 
     smo.Complexity = 1.0; 

     // Run the learning algorithm 
     double error = smo.Run(); 

     // Compute the decision output for one of the input vectors 

***** эта линия показывает ошибку. В нем говорится, что «SVM» не существует.

 int decision = System.Math.Sign(svm.Compute(inputs[0])); 

     Console.Write(decision); 
    } 
} 

}

ответ

0

Это опечатка в документации. Он должен был читать

int decision = System.Math.Sign(machine.Compute(inputs[0])); 

Благодарим за выявление проблемы!