Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/15/11 14:54:43 (14 years ago)
Author:
abeham
Message:

#1465

  • updated branch with changes from trunk
  • fixed some bugs
  • introduced secondary x-axis option
Location:
branches/histogram
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/histogram

  • branches/histogram/HeuristicLab.Algorithms.DataAnalysis/3.4/SupportVectorMachine/SupportVectorMachineUtil.cs

    r5809 r6011  
    4141      int maxNodeIndex = 0;
    4242      int svmProblemRowIndex = 0;
     43      List<string> inputVariablesList = inputVariables.ToList();
    4344      foreach (int row in rowIndices) {
    4445        tempRow = new List<SVM.Node>();
    45         foreach (var inputVariable in inputVariables) {
    46           int col = dataset.GetVariableIndex(inputVariable);
    47           double value = dataset[row, col];
     46        int colIndex = 1; // make sure the smallest node index for SVM = 1
     47        foreach (var inputVariable in inputVariablesList) {
     48          double value = dataset[row, dataset.GetVariableIndex(inputVariable)];
     49          // SVM also works with missing values
     50          // => don't add NaN values in the dataset to the sparse SVM matrix representation
    4851          if (!double.IsNaN(value)) {
    49             int nodeIndex = col + 1; // make sure the smallest nodeIndex is 1 (libSVM convention)
    50             tempRow.Add(new SVM.Node(nodeIndex, value));
    51             if (nodeIndex > maxNodeIndex) maxNodeIndex = nodeIndex;
     52            tempRow.Add(new SVM.Node(colIndex, value)); // nodes must be sorted in ascending ordered by column index
     53            if (colIndex > maxNodeIndex) maxNodeIndex = colIndex;
    5254          }
     55          colIndex++;
    5356        }
    54         nodes[svmProblemRowIndex++] = tempRow.OrderBy(x => x.Index).ToArray(); // make sure the values are sorted by node index
     57        nodes[svmProblemRowIndex++] = tempRow.ToArray();
    5558      }
    5659
Note: See TracChangeset for help on using the changeset viewer.