Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/16/09 11:34:22 (15 years ago)
Author:
gkronber
Message:

Removed variable AllowedFeatures in all modeling algorithms. #709

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

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Modeling/3.2/ProblemInjector.cs

    r2162 r2165  
    7777
    7878      AddVariableInfo(new VariableInfo("MaxNumberOfTrainingSamples", "Maximal number of training samples to use (optional)", typeof(IntData), VariableKind.In));
     79      AddVariableInfo(new VariableInfo("NumberOfInputVariables", "The number of available input variables", typeof(IntData), VariableKind.New));
    7980    }
    8081
     
    9798      Dataset scopeDataset = CreateNewDataset(operatorDataset, targetVariable, operatorAllowedFeatures);
    9899
    99       ItemList<IntData> allowedFeatures = new ItemList<IntData>();
    100       allowedFeatures.AddRange(Enumerable.Range(1, scopeDataset.Columns -1 ).Select(x=>new IntData(x)));
    101 
    102100      scope.AddVariable(new Variable("Dataset", scopeDataset));
    103       scope.AddVariable(new Variable("AllowedFeatures", allowedFeatures));
    104101      scope.AddVariable(new Variable("TargetVariable", new IntData(0)));
     102      scope.AddVariable(new Variable("NumberOfInputVariables", new IntData(scopeDataset.Columns - 1)));
    105103
    106104      int trainingStart = GetVariableValue<IntData>("TrainingSamplesStart", scope, true).Data;
  • trunk/sources/HeuristicLab.Modeling/3.2/VariableEvaluationImpactCalculator.cs

    r2136 r2165  
    5858    }
    5959
    60     protected override double[] CalculateValue(IScope scope, Dataset dataset, int targetVariable, ItemList<IntData> allowedFeatures, int start, int end) {
    61       return GetOutputs(scope, dataset, targetVariable, allowedFeatures, start, end);
     60    protected override double[] CalculateValue(IScope scope, Dataset dataset, int targetVariable, int start, int end) {
     61      return GetOutputs(scope, dataset, targetVariable, start, end);
    6262    }
    6363
     
    7575    }
    7676
    77     protected abstract double[] GetOutputs(IScope scope, Dataset dataset, int targetVariable, ItemList<IntData> allowedFeatures, int start, int end);
     77    protected abstract double[] GetOutputs(IScope scope, Dataset dataset, int targetVariable, int start, int end);
    7878  }
    7979}
  • trunk/sources/HeuristicLab.Modeling/3.2/VariableImpactCalculatorBase.cs

    r2043 r2165  
    3434
    3535    public override string Description {
    36       get { return @"Calculates the impact of all allowed input variables on the model."; }
     36      get { return @"Calculates the impact of all input variables on the model."; }
    3737    }
    3838
     
    4747      AddVariableInfo(new VariableInfo("Dataset", "Dataset", typeof(Dataset), VariableKind.In));
    4848      AddVariableInfo(new VariableInfo("TargetVariable", "TargetVariable", typeof(IntData), VariableKind.In));
    49       AddVariableInfo(new VariableInfo("AllowedFeatures", "Indexes of allowed input variables", typeof(ItemList<IntData>), VariableKind.In));
    5049      AddVariableInfo(new VariableInfo("TrainingSamplesStart", "TrainingSamplesStart", typeof(IntData), VariableKind.In));
    5150      AddVariableInfo(new VariableInfo("TrainingSamplesEnd", "TrainingSamplesEnd", typeof(IntData), VariableKind.In));
     
    5453
    5554    public override IOperation Apply(IScope scope) {
    56       ItemList<IntData> allowedFeatures = GetVariableValue<ItemList<IntData>>("AllowedFeatures", scope, true);
    5755      int targetVariable = GetVariableValue<IntData>("TargetVariable", scope, true).Data;
    5856      Dataset dataset = GetVariableValue<Dataset>("Dataset", scope, true);
     
    6159      int end = GetVariableValue<IntData>("TrainingSamplesEnd", scope, true).Data;
    6260
    63       T referenceValue = CalculateValue(scope, dataset, targetVariable, allowedFeatures, start, end);
    64       double[] impacts = new double[allowedFeatures.Count];
     61      T referenceValue = CalculateValue(scope, dataset, targetVariable, start, end);
     62      double[] impacts = new double[dataset.Columns];
    6563
    66       for (int i = 0; i < allowedFeatures.Count && !abortRequested; i++) {
    67         int currentVariable = allowedFeatures[i].Data;
    68         var oldValues = ReplaceVariableValues(dirtyDataset, currentVariable, CalculateNewValues(dirtyDataset, currentVariable, start, end), start, end);
    69         T newValue = CalculateValue(scope, dirtyDataset, targetVariable, allowedFeatures, start, end);
    70         impacts[i] = CalculateImpact(referenceValue, newValue);
    71         ReplaceVariableValues(dirtyDataset, currentVariable, oldValues, start, end);
     64      for (int i = 0; i < impacts.Length && !abortRequested; i++) {
     65        int currentVariable = i;
     66        if (currentVariable != targetVariable) {
     67          var oldValues = ReplaceVariableValues(dirtyDataset, currentVariable, CalculateNewValues(dirtyDataset, currentVariable, start, end), start, end);
     68          T newValue = CalculateValue(scope, dirtyDataset, targetVariable, start, end);
     69          impacts[i] = CalculateImpact(referenceValue, newValue);
     70          ReplaceVariableValues(dirtyDataset, currentVariable, oldValues, start, end);
     71        }
    7272      }
    7373
     
    7676
    7777        ItemList variableImpacts = new ItemList();
    78         for (int i = 0; i < allowedFeatures.Count; i++) {
    79           int currentVariable = allowedFeatures[i].Data;
    80           ItemList row = new ItemList();
    81           row.Add(new StringData(dataset.GetVariableName(currentVariable)));
    82           row.Add(new DoubleData(impacts[i]));
    83           variableImpacts.Add(row);
     78        for (int i = 0; i < impacts.Length; i++) {
     79          int currentVariable = i;
     80          if (currentVariable != targetVariable) {
     81            ItemList row = new ItemList();
     82            row.Add(new StringData(dataset.GetVariableName(currentVariable)));
     83            row.Add(new DoubleData(impacts[i]));
     84            variableImpacts.Add(row);
     85          }
    8486        }
    8587
     
    9193    }
    9294
    93     protected abstract T CalculateValue(IScope scope, Dataset dataset, int targetVariable, ItemList<IntData> allowedFeatures, int start, int end);
     95    protected abstract T CalculateValue(IScope scope, Dataset dataset, int targetVariable, int start, int end);
    9496
    9597    protected abstract double CalculateImpact(T referenceValue, T newValue);
  • trunk/sources/HeuristicLab.Modeling/3.2/VariableQualityImpactCalculator.cs

    r2043 r2165  
    4343    }
    4444
    45     protected override double CalculateValue(IScope scope, Dataset dataset, int targetVariable, ItemList<IntData> allowedFeatures, int start, int end) {
    46       return CalculateQuality(scope, dataset, targetVariable, allowedFeatures, start, end);
     45    protected override double CalculateValue(IScope scope, Dataset dataset, int targetVariable, int start, int end) {
     46      return CalculateQuality(scope, dataset, targetVariable, start, end);
    4747    }
    4848
    49     protected abstract double CalculateQuality(IScope scope, Dataset dataset, int targetVariable, ItemList<IntData> allowedFeatures, int start, int end);
     49    protected abstract double CalculateQuality(IScope scope, Dataset dataset, int targetVariable, int start, int end);
    5050  }
    5151}
Note: See TracChangeset for help on using the changeset viewer.