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.GP.StructureIdentification/3.3
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/GPEvaluatorBase.cs

    r2341 r2440  
    3232      AddVariableInfo(new VariableInfo("FunctionTree", "The function tree that should be evaluated", typeof(IGeneticProgrammingModel), VariableKind.In));
    3333      AddVariableInfo(new VariableInfo("Dataset", "Dataset with all samples on which to apply the function", typeof(Dataset), VariableKind.In));
    34       AddVariableInfo(new VariableInfo("TargetVariable", "Index of the column of the dataset that holds the target variable", typeof(IntData), VariableKind.In));
     34      AddVariableInfo(new VariableInfo("TargetVariable", "Name of the target variable", typeof(StringData), VariableKind.In));
    3535      AddVariableInfo(new VariableInfo("TotalEvaluatedNodes", "Number of evaluated nodes", typeof(DoubleData), VariableKind.In | VariableKind.Out));
    3636      AddVariableInfo(new VariableInfo("SamplesStart", "Start index of samples in dataset to evaluate", typeof(IntData), VariableKind.In));
     
    4141    public override IOperation Apply(IScope scope) {
    4242      // get all variable values
    43       int targetVariable = GetVariableValue<IntData>("TargetVariable", scope, true).Data;
    4443      Dataset dataset = GetVariableValue<Dataset>("Dataset", scope, true);
     44      int targetVariable = dataset.GetVariableIndex(GetVariableValue<StringData>("TargetVariable", scope, true).Data);
    4545      IGeneticProgrammingModel gpModel = GetVariableValue<IGeneticProgrammingModel>("FunctionTree", scope, true);
    4646      double totalEvaluatedNodes = scope.GetVariableValue<DoubleData>("TotalEvaluatedNodes", true).Data;
  • trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/HL2TreeEvaluatorInjector.cs

    r2327 r2440  
    3737      AddVariableInfo(new VariableInfo("TrainingSamplesStart", "Start index of training set", typeof(DoubleData), VariableKind.In));
    3838      AddVariableInfo(new VariableInfo("TrainingSamplesEnd", "End index of training set", typeof(DoubleData), VariableKind.In));
    39       AddVariableInfo(new VariableInfo("TargetVariable", "Index of the target variable", typeof(IntData), VariableKind.In));
     39      AddVariableInfo(new VariableInfo("TargetVariable", "Name of the target variable", typeof(StringData), VariableKind.In));
    4040      AddVariableInfo(new VariableInfo("PunishmentFactor", "The punishment factor limits the estimated values to a certain range", typeof(DoubleData), VariableKind.In));
    4141      AddVariableInfo(new VariableInfo("TreeEvaluator", "The tree evaluator to evaluate models", typeof(ITreeEvaluator), VariableKind.New));
     
    5151      int start = GetVariableValue<IntData>("TrainingSamplesStart", scope, true).Data;
    5252      int end = GetVariableValue<IntData>("TrainingSamplesEnd", scope, true).Data;
    53       int targetVariable = GetVariableValue<IntData>("TargetVariable", scope, true).Data;
     53      string targetVariable = GetVariableValue<StringData>("TargetVariable", scope, true).Data;
    5454      double mean = dataset.GetMean(targetVariable, start, end);
    5555      double range = dataset.GetRange(targetVariable, start, end);
  • trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/HL3TreeEvaluatorInjector.cs

    r2327 r2440  
    3737      AddVariableInfo(new VariableInfo("TrainingSamplesStart", "Start index of training set", typeof(DoubleData), VariableKind.In));
    3838      AddVariableInfo(new VariableInfo("TrainingSamplesEnd", "End index of training set", typeof(DoubleData), VariableKind.In));
    39       AddVariableInfo(new VariableInfo("TargetVariable", "Index of the target variable", typeof(IntData), VariableKind.In));
     39      AddVariableInfo(new VariableInfo("TargetVariable", "Name of the target variable", typeof(StringData), VariableKind.In));
    4040      AddVariableInfo(new VariableInfo("PunishmentFactor", "The punishment factor limits the estimated values to a certain range", typeof(DoubleData), VariableKind.In));
    4141      AddVariableInfo(new VariableInfo("TreeEvaluator", "The tree evaluator to evaluate models", typeof(ITreeEvaluator), VariableKind.New));
     
    5151      int start = GetVariableValue<IntData>("TrainingSamplesStart", scope, true).Data;
    5252      int end = GetVariableValue<IntData>("TrainingSamplesEnd", scope, true).Data;
    53       int targetVariable = GetVariableValue<IntData>("TargetVariable", scope, true).Data;
     53      string targetVariable = GetVariableValue<StringData>("TargetVariable", scope, true).Data;
    5454      double mean = dataset.GetMean(targetVariable, start, end);
    5555      double range = dataset.GetRange(targetVariable, start, end);
  • trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/OffspringSelectionGPRegression.cs

    r2419 r2440  
    3939    public override string Name { get { return "OffspringSelectionGP - StructureIdentification"; } }
    4040
    41     public virtual int TargetVariable {
    42       get { return ProblemInjector.GetVariableValue<IntData>("TargetVariable", null, false).Data; }
    43       set { ProblemInjector.GetVariableValue<IntData>("TargetVariable", null, false).Data = value; }
     41    public virtual string TargetVariable {
     42      get { return ProblemInjector.GetVariableValue<StringData>("TargetVariable", null, false).Data; }
     43      set { ProblemInjector.GetVariableValue<StringData>("TargetVariable", null, false).Data = value; }
    4444    }
    4545
     
    5757      }
    5858    }
    59     public IEnumerable<int> AllowedVariables {
     59    public IEnumerable<string> AllowedVariables {
    6060      get {
    61         ItemList<IntData> allowedVariables = ProblemInjector.GetVariableValue<ItemList<IntData>>("AllowedFeatures", null, false);
     61        ItemList<StringData> allowedVariables = ProblemInjector.GetVariableValue<ItemList<StringData>>("AllowedFeatures", null, false);
    6262        return allowedVariables.Select(x => x.Data);
    6363      }
    6464      set {
    65         ItemList<IntData> allowedVariables = ProblemInjector.GetVariableValue<ItemList<IntData>>("AllowedFeatures", null, false);
    66         foreach (int x in value) allowedVariables.Add(new IntData(x));
     65        ItemList<StringData> allowedVariables = ProblemInjector.GetVariableValue<ItemList<StringData>>("AllowedFeatures", null, false);
     66        foreach (string x in value) allowedVariables.Add(new StringData(x));
    6767      }
    6868    }
  • trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/PredictorBuilder.cs

    r2332 r2440  
    4040      AddVariableInfo(new VariableInfo("TrainingSamplesStart", "Start index of training set", typeof(DoubleData), VariableKind.In));
    4141      AddVariableInfo(new VariableInfo("TrainingSamplesEnd", "End index of training set", typeof(DoubleData), VariableKind.In));
    42       AddVariableInfo(new VariableInfo("TargetVariable", "Index of 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("Predictor", "The predictor combines the function tree and the evaluator and can be used to generate estimated values", typeof(IPredictor), VariableKind.New));
    4444    }
     
    5555      int start = GetVariableValue<IntData>("TrainingSamplesStart", scope, true).Data;
    5656      int end = GetVariableValue<IntData>("TrainingSamplesEnd", scope, true).Data;
    57       int targetVariable = GetVariableValue<IntData>("TargetVariable", scope, true).Data;
     57      string targetVariable = GetVariableValue<StringData>("TargetVariable", scope, true).Data;
    5858      IPredictor predictor = CreatePredictor(model, evaluator, punishmentFactor, dataset, targetVariable, start, end);
    5959      scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("Predictor"), predictor));
  • trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/StandardGPRegression.cs

    r2419 r2440  
    3939    public override string Name { get { return "StandardGP - StructureIdentification"; } }
    4040
    41     public virtual int TargetVariable {
    42       get { return ProblemInjector.GetVariableValue<IntData>("TargetVariable", null, false).Data; }
    43       set { ProblemInjector.GetVariableValue<IntData>("TargetVariable", null, false).Data = value; }
     41    public virtual string TargetVariable {
     42      get { return ProblemInjector.GetVariableValue<StringData>("TargetVariable", null, false).Data; }
     43      set { ProblemInjector.GetVariableValue<StringData>("TargetVariable", null, false).Data = value; }
    4444    }
    4545
     
    5858    }
    5959
    60     public IEnumerable<int> AllowedVariables {
     60    public IEnumerable<string> AllowedVariables {
    6161      get {
    62         ItemList<IntData> allowedVariables = ProblemInjector.GetVariableValue<ItemList<IntData>>("AllowedFeatures", null, false);
     62        ItemList<StringData> allowedVariables = ProblemInjector.GetVariableValue<ItemList<StringData>>("AllowedFeatures", null, false);
    6363        return allowedVariables.Select(x => x.Data);
    6464      }
    6565      set {
    66         ItemList<IntData> allowedVariables = ProblemInjector.GetVariableValue<ItemList<IntData>>("AllowedFeatures", null, false);
    67         foreach (int x in value) allowedVariables.Add(new IntData(x));
     66        ItemList<StringData> allowedVariables = ProblemInjector.GetVariableValue<ItemList<StringData>>("AllowedFeatures", null, false);
     67        foreach (string x in value) allowedVariables.Add(new StringData(x));
    6868      }
    6969    }
Note: See TracChangeset for help on using the changeset viewer.