Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/05/12 11:58:17 (12 years ago)
Author:
mkommend
Message:

#1081: Merged trunk changes and fixed compilation errors due to the merge.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.TimeSeries/HeuristicLab.Algorithms.DataAnalysis/3.4/SupportVectorMachine/SupportVectorMachineUtil.cs

    r7259 r8742  
    2323using System.Linq;
    2424using HeuristicLab.Problems.DataAnalysis;
     25using LibSVM;
    2526
    2627namespace HeuristicLab.Algorithms.DataAnalysis {
     
    3233    /// <param name="rowIndices">The rows of the dataset that should be contained in the resulting SVM-problem</param>
    3334    /// <returns>A problem data type that can be used to train a support vector machine.</returns>
    34     public static SVM.Problem CreateSvmProblem(Dataset dataset, string targetVariable, IEnumerable<string> inputVariables, IEnumerable<int> rowIndices) {
     35    public static svm_problem CreateSvmProblem(Dataset dataset, string targetVariable, IEnumerable<string> inputVariables, IEnumerable<int> rowIndices) {
    3536      double[] targetVector =
    3637        dataset.GetDoubleValues(targetVariable, rowIndices).ToArray();
    3738
    38       SVM.Node[][] nodes = new SVM.Node[targetVector.Length][];
    39       List<SVM.Node> tempRow;
     39      svm_node[][] nodes = new svm_node[targetVector.Length][];
     40      List<svm_node> tempRow;
    4041      int maxNodeIndex = 0;
    4142      int svmProblemRowIndex = 0;
    4243      List<string> inputVariablesList = inputVariables.ToList();
    4344      foreach (int row in rowIndices) {
    44         tempRow = new List<SVM.Node>();
     45        tempRow = new List<svm_node>();
    4546        int colIndex = 1; // make sure the smallest node index for SVM = 1
    4647        foreach (var inputVariable in inputVariablesList) {
     
    4950          // => don't add NaN values in the dataset to the sparse SVM matrix representation
    5051          if (!double.IsNaN(value)) {
    51             tempRow.Add(new SVM.Node(colIndex, value)); // nodes must be sorted in ascending ordered by column index
     52            tempRow.Add(new svm_node() { index = colIndex, value = value }); // nodes must be sorted in ascending ordered by column index
    5253            if (colIndex > maxNodeIndex) maxNodeIndex = colIndex;
    5354          }
     
    5758      }
    5859
    59       return new SVM.Problem(targetVector.Length, targetVector, nodes, maxNodeIndex);
     60      return new svm_problem() { l = targetVector.Length, y = targetVector, x = nodes };
    6061    }
    6162  }
Note: See TracChangeset for help on using the changeset viewer.