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)

Location:
trunk/sources/HeuristicLab.SupportVectorMachines/3.2
Files:
4 edited

Legend:

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

    r2421 r2440  
    5252      Dataset ds = GetVariableValue<Dataset>("Dataset", scope, true);
    5353      SVMModel model = GetVariableValue<SVMModel>("SVMModel", scope, true);
    54       int targetVariable = GetVariableValue<IntData>("TargetVariable", scope, true).Data;
     54      string targetVariable = GetVariableValue<StringData>("TargetVariable", scope, true).Data;
    5555      int start = GetVariableValue<IntData>("TrainingSamplesStart", scope, true).Data;
    5656      int end = GetVariableValue<IntData>("TrainingSamplesEnd", scope, true).Data;
     
    6161      double punishmentFactor = GetVariableValue<DoubleData>("PunishmentFactor", scope, true).Data;
    6262
    63       string targetVariableName = ds.GetVariableName(targetVariable);
     63     
    6464      ItemList inputVariables = GetVariableValue<ItemList>("InputVariables", scope, true);
    6565      var inputVariableNames = from x in inputVariables
     
    6969      double range = ds.GetRange(targetVariable, start, end);
    7070
    71       Predictor predictor = new Predictor(model, targetVariableName, inputVariableNames, minTimeOffset, maxTimeOffset);
     71      Predictor predictor = new Predictor(model, targetVariable, inputVariableNames, minTimeOffset, maxTimeOffset);
    7272      predictor.LowerPredictionLimit = mean - punishmentFactor * range;
    7373      predictor.UpperPredictionLimit = mean + punishmentFactor * range;
  • TabularUnified trunk/sources/HeuristicLab.SupportVectorMachines/3.2/SupportVectorCreator.cs

    r2421 r2440  
    4040      //Dataset infos
    4141      AddVariableInfo(new VariableInfo("Dataset", "Dataset with all samples on which to apply the function", typeof(Dataset), VariableKind.In));
    42       AddVariableInfo(new VariableInfo("TargetVariable", "Index of the column of the dataset that holds the target variable", typeof(IntData), VariableKind.In));
     42      AddVariableInfo(new VariableInfo("TargetVariable", "Name of the target variable", typeof(StringData), VariableKind.In));
    4343      AddVariableInfo(new VariableInfo("InputVariables", "List of allowed input variable names", typeof(ItemList), VariableKind.In));
    4444      AddVariableInfo(new VariableInfo("SamplesStart", "Start index of samples in dataset to evaluate", typeof(IntData), VariableKind.In));
     
    7070      abortRequested = false;
    7171      Dataset dataset = GetVariableValue<Dataset>("Dataset", scope, true);
    72       int targetVariable = GetVariableValue<IntData>("TargetVariable", scope, true).Data;
    73       ItemList inputVaribales = GetVariableValue<ItemList>("InputVariables", scope, true);
    74       var inputVariableNames = from x in inputVaribales
     72      string targetVariable = GetVariableValue<StringData>("TargetVariable", scope, true).Data;
     73      int targetVariableIndex = dataset.GetVariableIndex(targetVariable);
     74      ItemList inputVariables = GetVariableValue<ItemList>("InputVariables", scope, true);
     75      var inputVariableNames = from x in inputVariables
    7576                               select ((StringData)x).Data;
    7677      int start = GetVariableValue<IntData>("SamplesStart", scope, true).Data;
     
    9394      parameter.Probability = false;
    9495
    95       SVM.Problem problem = SVMHelper.CreateSVMProblem(dataset, targetVariable, inputVariableNames, start, end, minTimeOffset, maxTimeOffset);
     96      SVM.Problem problem = SVMHelper.CreateSVMProblem(dataset, targetVariableIndex, inputVariableNames, start, end, minTimeOffset, maxTimeOffset);
    9697      SVM.RangeTransform rangeTransform = SVM.RangeTransform.Compute(problem);
    9798      SVM.Problem scaledProblem = rangeTransform.Scale(problem);
  • TabularUnified 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      }
  • TabularUnified trunk/sources/HeuristicLab.SupportVectorMachines/3.2/SupportVectorRegression.cs

    r2419 r2440  
    5252    }
    5353
    54     public int TargetVariable {
    55       get { return ProblemInjector.GetVariableValue<IntData>("TargetVariable", null, false).Data; }
    56       set { ProblemInjector.GetVariableValue<IntData>("TargetVariable", null, false).Data = value; }
     54    public string TargetVariable {
     55      get { return ProblemInjector.GetVariableValue<StringData>("TargetVariable", null, false).Data; }
     56      set { ProblemInjector.GetVariableValue<StringData>("TargetVariable", null, false).Data = value; }
    5757    }
    5858
     
    7878      }
    7979    }
    80     public IEnumerable<int> AllowedVariables {
     80    public IEnumerable<string> AllowedVariables {
    8181      get {
    82         ItemList<IntData> allowedVariables = ProblemInjector.GetVariableValue<ItemList<IntData>>("AllowedFeatures", null, false);
     82        ItemList<StringData> allowedVariables = ProblemInjector.GetVariableValue<ItemList<StringData>>("AllowedFeatures", null, false);
    8383        return allowedVariables.Select(x => x.Data);
    8484      }
    8585      set {
    86         ItemList<IntData> allowedVariables = ProblemInjector.GetVariableValue<ItemList<IntData>>("AllowedFeatures", null, false);
    87         foreach (int x in value) allowedVariables.Add(new IntData(x));
     86        ItemList<StringData> allowedVariables = ProblemInjector.GetVariableValue<ItemList<StringData>>("AllowedFeatures", null, false);
     87        foreach (string x in value) allowedVariables.Add(new StringData(x));
    8888      }
    8989    }
Note: See TracChangeset for help on using the changeset viewer.