Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/14/09 19:56:04 (15 years ago)
Author:
gkronber
Message:
  • introduced a variablename to index mapping for SVM models (to make sure we can use the model for prediction in the model analyzer)
  • added support to enable and disable algorithms in the dispatcher and removed DispatcherBase
  • fixed bugs when calculating variable impacts and reading the final model of GP algorithms

#722 (IModel should provide a Predict() method to get predicted values for an input vector)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.SupportVectorMachines/3.2/SVMHelper.cs

    r2285 r2290  
    99namespace HeuristicLab.SupportVectorMachines {
    1010  public class SVMHelper {
     11
    1112    public static SVM.Problem CreateSVMProblem(Dataset dataset, int targetVariable, int start, int end) {
     13      return CreateSVMProblem(dataset, targetVariable, Enumerable.Range(0, dataset.Columns).ToDictionary<int, int>(x => x), start, end);
     14    }
     15
     16    public static SVM.Problem CreateSVMProblem(Dataset dataset, int targetVariable, Dictionary<int, int> columnMapping, int start, int end) {
    1217      int rowCount = end - start;
    1318      List<int> skippedFeatures = new List<int>();
     
    2429      for (int i = 0; i < rowCount; i++) {
    2530        double value = dataset.GetValue(start + i, targetVariable);
    26           targetVector[i] = value;
     31        targetVector[i] = value;
    2732      }
    28       targetVector = targetVector.Where(x=> !double.IsNaN(x)).ToArray();
     33      targetVector = targetVector.Where(x => !double.IsNaN(x)).ToArray();
    2934
    3035      SVM.Node[][] nodes = new SVM.Node[targetVector.Length][];
     
    3439        tempRow = new List<SVM.Node>();
    3540        for (int col = 0; col < dataset.Columns; col++) {
    36           if (!skippedFeatures.Contains(col) && col!=targetVariable) {
     41          if (!skippedFeatures.Contains(col) && col != targetVariable && columnMapping.ContainsKey(col)) {
    3742            double value = dataset.GetValue(start + row, col);
    3843            if (!double.IsNaN(value))
    39               tempRow.Add(new SVM.Node(col + 1, value));
     44              tempRow.Add(new SVM.Node(columnMapping[col], value));
    4045          }
    4146        }
Note: See TracChangeset for help on using the changeset viewer.