- Timestamp:
- 04/11/11 18:41:03 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/SupportVectorMachine/SupportVectorMachineUtil.cs
r5809 r6002 41 41 int maxNodeIndex = 0; 42 42 int svmProblemRowIndex = 0; 43 List<string> inputVariablesList = inputVariables.ToList(); 43 44 foreach (int row in rowIndices) { 44 45 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 48 51 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; 52 54 } 55 colIndex++; 53 56 } 54 nodes[svmProblemRowIndex++] = tempRow. OrderBy(x => x.Index).ToArray(); // make sure the values are sorted by node index57 nodes[svmProblemRowIndex++] = tempRow.ToArray(); 55 58 } 56 59
Note: See TracChangeset
for help on using the changeset viewer.