2016-03-19 3 views
2

Iは、多クラスサポートベクトルマシンのためのドキュメントに例を挙げて取り組んでいます - http://accord-framework.net/docs/html/T_Accord_MachineLearning_VectorMachines_MultilabelSupportVectorMachine.htmアコードとMulit-ラベルサポートベクターマシン

けれども、私は0、エラー率が届かない、とするときI値を計算しようとすると、出力値が得られません。この例に何か問題がありますか?

static void Main(string[] args) 
    { 
     // Sample input data 
     double[][] inputs = 
     { 
      new double[] { 0 }, 
      new double[] { 1 }, 
      new double[] { 2 }, 
      new double[] { 3 }, 
     }; 

     // Outputs for each of the inputs 
     int[][] outputs = 
      { 
       new[] {1,-1,-1,-1}, 
       new[] {-1,1,-1,-1}, 
       new[] {-1,-1,1,-1}, 
       new[] {-1,-1,-1,1}, 
      }; 

     // Create a new Linear kernel 
     IKernel kernel = new Linear(); 

     // Create a new Multi-class Support Vector Machine with one input, 
     // using the linear kernel and for four disjoint classes. 
     var machine = new MultilabelSupportVectorMachine(1, kernel, 4); 

     // Create the Multi-label learning algorithm for the machine 
     var teacher = new MultilabelSupportVectorLearning(machine, inputs, outputs); 

     // Configure the learning algorithm to use SMO to train the 
     // underlying SVMs in each of the binary class subproblems. 
     teacher.Algorithm = (svm, classInputs, classOutputs, i, j) => 
      new SequentialMinimalOptimization(svm, classInputs, classOutputs); 

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

     error = teacher.Run(); // 0.1875 error rate 
     var answer = machine.Compute(new double[] {2}); // gives -1,-1,-1,-1, instead of -1,-1,1,-1 

エラー率はゼロであるべきであり、なぜ0の入力のみが右出力を与えるように見えるのでしょうか?

+0

だから、なぜ近くの投票?それは私のストーカーが証明するべきポイントを持っていますか? – user3791372

+0

知識がなく、答えを知らない人々は、常に近くに投票するでしょう。あなたもそれを学ぶ:) – MonsterMMORPG

答えて

0

質問に答えるには、その特定の例に何か問題があった可能性が非常に高いです。ほとんどの例は、昨年施行された新しい.Learn()APIを反映するように更新されています。

マルチラベルサポートベクターマシンはまた、新しいAPIによりアドレスを変更し、

になりましたそして今、それはこの例が含まれているために今、あなたはそのドキュメントページが表示されることがあり中でも:

// Let's say we have the following data to be classified 
// into three possible classes. Those are the samples: 
// 
double[][] inputs = 
{ 
    //    input   output 
    new double[] { 0, 1, 1, 0 }, // 0 
    new double[] { 0, 1, 0, 0 }, // 0 
    new double[] { 0, 0, 1, 0 }, // 0 
    new double[] { 0, 1, 1, 0 }, // 0 
    new double[] { 0, 1, 0, 0 }, // 0 
    new double[] { 1, 0, 0, 0 }, // 1 
    new double[] { 1, 0, 0, 0 }, // 1 
    new double[] { 1, 0, 0, 1 }, // 1 
    new double[] { 0, 0, 0, 1 }, // 1 
    new double[] { 0, 0, 0, 1 }, // 1 
    new double[] { 1, 1, 1, 1 }, // 2 
    new double[] { 1, 0, 1, 1 }, // 2 
    new double[] { 1, 1, 0, 1 }, // 2 
    new double[] { 0, 1, 1, 1 }, // 2 
    new double[] { 1, 1, 1, 1 }, // 2 
}; 

int[] outputs = // those are the class labels 
{ 
    0, 0, 0, 0, 0, 
    1, 1, 1, 1, 1, 
    2, 2, 2, 2, 2, 
}; 

// Create the multi-class learning algorithm for the machine 
var teacher = new MulticlassSupportVectorLearning<Gaussian>() 
{ 
    // Configure the learning algorithm to use SMO to train the 
    // underlying SVMs in each of the binary class subproblems. 
    Learner = (param) => new SequentialMinimalOptimization<Gaussian>() 
    { 
     // Estimate a suitable guess for the Gaussian kernel's parameters. 
     // This estimate can serve as a starting point for a grid search. 
     UseKernelEstimation = true 
    } 
}; 

// Configure parallel execution options 
teacher.ParallelOptions.MaxDegreeOfParallelism = 1; 

// Learn a machine 
var machine = teacher.Learn(inputs, outputs); 

// Obtain class predictions for each sample 
int[] predicted = machine.Decide(inputs); 

// Get class scores for each sample 
double[] scores = machine.Score(inputs); 

// Compute classification error 
double error = new ZeroOneLoss(outputs).Loss(predicted); 
関連する問題