private void btnKernel_Click(object sender, EventArgs e)
    {
      double[,] sourceMatrix;
      double[,] inputs;
      int[] labels;

      GetData(out sourceMatrix, out inputs, out labels);

      //_svm.SimpleSMO(inputs, labels);
      // Perform classification
      SequentialMinimalOptimization smo;
      var kernel = new Gaussian(1.2236000);
      // Creates the Support Vector Machine using the selected kernel
      var svm = new KernelSupportVectorMachine(kernel, 2);
      //SupportVectorMachine svm = new SupportVectorMachine(2);

      // Creates a new instance of the SMO Learning Algorithm
      smo = new SequentialMinimalOptimization(svm, inputs.ToArray(), labels);

      // Set learning parameters
      smo.Complexity = 1.0;
      smo.Tolerance = 0.001;


      bool converged = true;

      try
      {
        // Run
        double error = smo.Run();
      }
      catch
      {
        converged = false;
      }

      //var a = sourceMatrix.Submatrix(0, sourceMatrix.GetLength(0) - 1, 0, 2);
      //CreateScatterplot(graphInput, a, svm);

      var ranges = Matrix.Range(sourceMatrix);
      double[][] map = Matrix.CartesianProduct(
          Matrix.Interval(ranges[0], 0.05),
          Matrix.Interval(ranges[1], 0.05));

      var result = map.Apply(svm.Compute).Apply(Math.Sign);

      var graph2 = map.ToMatrix().InsertColumn(result.ToDouble());

      CreateDecisionBoundaryplot(graphInput, graph2, sourceMatrix);
    }
    private void btnSimpleSMO_Click(object sender, EventArgs e)
    {
      double[,] sourceMatrix;
      double[,] inputs;
      int[] labels;

      GetData(out sourceMatrix, out inputs, out labels);

      //_svm.SimpleSMO(inputs, labels);
      // Perform classification
      SequentialMinimalOptimization smo;

      // Creates the Support Vector Machine using the selected kernel
      //svm = new KernelSupportVectorMachine(kernel, 2);
      SupportVectorMachine svm = new SupportVectorMachine(2);

      // Creates a new instance of the SMO Learning Algorithm
      smo = new SequentialMinimalOptimization(svm, inputs.ToArray(), labels);

      // Set learning parameters
      smo.Complexity =1.0;
      smo.Tolerance = 0.001;


      bool converged = true;

      try
      {
        // Run
        double error = smo.Run();
      }
      catch 
      {
        converged = false;
      }

      var a = sourceMatrix.Submatrix(0, sourceMatrix.GetLength(0) - 1, 0, 2);
      CreateScatterplot(graphInput, a, svm);
    }