Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/10/09 19:05:34 (15 years ago)
Author:
gkronber
Message:

Implemented base classes for variable impact analysis and implemented specific operators for GP. #644 (Variable impact of CEDMA models should be calculated and stored in the result DB)

Location:
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3
Files:
2 added
3 edited

Legend:

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

    r2034 r2041  
    423423      model.TrainingMeanSquaredError = bestModelScope.GetVariableValue<DoubleData>("Quality", false).Data;
    424424      model.ValidationMeanSquaredError = bestModelScope.GetVariableValue<DoubleData>("ValidationQuality", false).Data;
     425      // calculate and set variable impacts
     426      VariableEvaluationImpactCalculator evaluationImpactCalculator = new VariableEvaluationImpactCalculator();
     427      VariableQualityImpactCalculator qualityImpactCalculator = new VariableQualityImpactCalculator();
     428
     429      evaluationImpactCalculator.Apply(bestModelScope);
     430      qualityImpactCalculator.Apply(bestModelScope);
     431
     432      ItemList evaluationImpacts = bestModelScope.GetVariableValue<ItemList>("VariableEvaluationImpacts", false);
     433      ItemList qualityImpacts = bestModelScope.GetVariableValue<ItemList>("VariableQualityImpacts", false);
     434      foreach (ItemList row in evaluationImpacts) {
     435        string variableName = ((StringData)row[0]).Data;
     436        double impact = ((DoubleData)row[0]).Data;
     437        model.SetVariableEvaluationImpact(variableName, impact);
     438      }
     439      foreach (ItemList row in qualityImpacts) {
     440        string variableName = ((StringData)row[0]).Data;
     441        double impact = ((DoubleData)row[0]).Data;
     442        model.SetVariableQualityImpact(variableName, impact);
     443      }
    425444      return model;
    426445    }
  • trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/SimpleEvaluator.cs

    r1891 r2041  
    3333    public SimpleEvaluator()
    3434      : base() {
    35       AddVariableInfo(new VariableInfo("Values", "The values of the target variable as predicted by the model and the original value of the target variable", typeof(ItemList), VariableKind.New | VariableKind.Out));
     35      AddVariableInfo(new VariableInfo("Values", "Target vs. predicted values", typeof(DoubleMatrixData), VariableKind.New | VariableKind.Out));
    3636    }
    3737
    3838    public override void Evaluate(IScope scope, ITreeEvaluator evaluator, Dataset dataset, int targetVariable, int start, int end, bool updateTargetValues) {
    39       ItemList values = GetVariableValue<ItemList>("Values", scope, false, false);
     39      DoubleMatrixData values = GetVariableValue<DoubleMatrixData>("Values", scope, false, false);
    4040      if (values == null) {
    41         values = new ItemList();
     41        values = new DoubleMatrixData();
    4242        IVariableInfo info = GetVariableInfo("Values");
    4343        if (info.Local)
     
    4646          scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName(info.FormalName), values));
    4747      }
    48       values.Clear();
     48
     49      double[,] v = new double[end - start, 2];
    4950
    5051      for (int sample = start; sample < end; sample++) {
    51         ItemList row = new ItemList();
    5252        double estimated = evaluator.Evaluate(sample);
    5353        double original = dataset.GetValue(sample, targetVariable);
     
    5555          dataset.SetValue(sample, targetVariable, estimated);
    5656        }
    57         row.Add(new DoubleData(estimated));
    58         row.Add(new DoubleData(original));
    59         values.Add(row);
     57        v[sample - start, 0] = original;
     58        v[sample - start, 1] = estimated;
    6059      }
     60      values.Data = v;
    6161    }
    6262  }
  • trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/HeuristicLab.GP.StructureIdentification-3.3.csproj

    r2034 r2041  
    140140    <Compile Include="Tangens.cs" />
    141141    <Compile Include="Variable.cs" />
     142    <Compile Include="Evaluators\VariableEvaluationImpactCalculator.cs" />
     143    <Compile Include="Evaluators\VariableQualityImpactCalculator.cs" />
    142144    <Compile Include="Xor.cs" />
    143145  </ItemGroup>
Note: See TracChangeset for help on using the changeset viewer.