Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/20/09 11:20:13 (15 years ago)
Author:
gkronber
Message:

Fixed #784 (ProblemInjector should be changed to read variable names instead of indexes for input and target variables)

File:
1 edited

Legend:

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

    r2421 r2440  
    3636      //Dataset infos
    3737      AddVariableInfo(new VariableInfo("Dataset", "Dataset with all samples on which to apply the function", typeof(Dataset), VariableKind.In));
    38       AddVariableInfo(new VariableInfo("TargetVariable", "Index of the column of the dataset that holds the target variable", typeof(IntData), VariableKind.In));
     38      AddVariableInfo(new VariableInfo("TargetVariable", "Name of the target variable", typeof(StringData), VariableKind.In));
    3939      AddVariableInfo(new VariableInfo("InputVariables", "List of allowed input variable names", typeof(ItemList), VariableKind.In));
    4040      AddVariableInfo(new VariableInfo("SamplesStart", "Start index of samples in dataset to evaluate", typeof(IntData), VariableKind.In));
     
    5252      var inputVariableNames = from x in inputVariables
    5353                               select ((StringData)x).Data;
    54       int targetVariable = GetVariableValue<IntData>("TargetVariable", scope, true).Data;
     54      string targetVariable = GetVariableValue<StringData>("TargetVariable", scope, true).Data;
     55      int targetVariableIndex = dataset.GetVariableIndex(targetVariable);
    5556      int start = GetVariableValue<IntData>("SamplesStart", scope, true).Data;
    5657      int end = GetVariableValue<IntData>("SamplesEnd", scope, true).Data;
     
    6162      SVMModel modelData = GetVariableValue<SVMModel>("SVMModel", scope, true);
    6263
    63       SVM.Problem problem = SVMHelper.CreateSVMProblem(dataset, targetVariable, inputVariableNames, start, end, minTimeOffset, maxTimeOffset);
     64      SVM.Problem problem = SVMHelper.CreateSVMProblem(dataset, targetVariableIndex, inputVariableNames, start, end, minTimeOffset, maxTimeOffset);
    6465      SVM.Problem scaledProblem = modelData.RangeTransform.Scale(problem);
    6566
    6667      double[,] values = new double[scaledProblem.Count, 2];
    6768      for (int i = 0; i < scaledProblem.Count; i++) {
    68         values[i, 0] = dataset.GetValue(start + i, targetVariable);
     69        values[i, 0] = dataset.GetValue(start + i, targetVariableIndex);
    6970        values[i, 1] = SVM.Prediction.Predict(modelData.Model, scaledProblem.X[i]);
    7071      }
Note: See TracChangeset for help on using the changeset viewer.