Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/07/08 16:59:35 (16 years ago)
Author:
gkronber
Message:

fixed small bugs in GP evaluators

Location:
trunk/sources/HeuristicLab.StructureIdentification/Evaluation
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.StructureIdentification/Evaluation/CoefficientOfDeterminationEvaluator.cs

    r363 r367  
    4444
    4545    public override double Evaluate(IScope scope, IFunctionTree functionTree, int targetVariable, Dataset dataset) {
     46      int trainingStart = GetVariableValue<IntData>("TrainingSamplesStart", scope, true).Data;
     47      int trainingEnd = GetVariableValue<IntData>("TrainingSamplesEnd", scope, true).Data;
    4648      double errorsSquaredSum = 0.0;
    4749      double originalDeviationTotalSumOfSquares = 0.0;
    48       double targetMean = dataset.GetMean(targetVariable);
     50      double targetMean = dataset.GetMean(targetVariable, trainingStart, trainingEnd);
    4951      functionTree.PrepareEvaluation(dataset);
    50       for(int sample = 0; sample < dataset.Rows; sample++) {
     52      for(int sample = trainingStart; sample < trainingEnd; sample++) {
    5153        double estimated = functionTree.Evaluate(sample);
    5254        double original = dataset.GetValue(sample, targetVariable);
  • trunk/sources/HeuristicLab.StructureIdentification/Evaluation/EarlyStoppingMeanSquaredErrorEvaluator.cs

    r363 r367  
    5959      }
    6060      double errorsSquaredSum = 0;
    61       double targetMean = dataset.GetMean(targetVariable);
     61      double targetMean = dataset.GetMean(targetVariable, trainingStart, trainingEnd);
    6262      functionTree.PrepareEvaluation(dataset);
    6363      for(int sample = trainingStart; sample < trainingEnd; sample++) {
  • trunk/sources/HeuristicLab.StructureIdentification/Evaluation/MCCEvaluator.cs

    r363 r367  
    4646    private double[] estimated = new double[1];
    4747    public override double Evaluate(IScope scope, IFunctionTree functionTree, int targetVariable, Dataset dataset) {
     48      int trainingStart = GetVariableValue<IntData>("TrainingSamplesStart", scope, true).Data;
     49      int trainingEnd = GetVariableValue<IntData>("TrainingSamplesEnd", scope, true).Data;
     50      int nSamples = trainingEnd-trainingStart;
    4851      double limit = GetVariableValue<DoubleData>("ClassSeparation", scope, false).Data;
    49       if(estimated.Length != dataset.Rows) {
    50         estimated = new double[dataset.Rows];
    51         original = new double[dataset.Rows];
     52      if(estimated.Length != nSamples) {
     53        estimated = new double[nSamples];
     54        original = new double[nSamples];
    5255      }
     56
    5357      double positive = 0;
    5458      double negative = 0;
    55       double targetMean = dataset.GetMean(targetVariable);
     59      double targetMean = dataset.GetMean(targetVariable, trainingStart, trainingEnd);
    5660      functionTree.PrepareEvaluation(dataset);
    57       for(int sample = 0; sample < dataset.Rows; sample++) {
     61      for(int sample = trainingStart; sample < trainingEnd; sample++) {
    5862        double est = functionTree.Evaluate(sample);
    5963        double orig = dataset.GetValue(sample, targetVariable);
     
    6569          est = targetMean - maximumPunishment;
    6670        }
    67         estimated[sample] = est;
    68         original[sample] = orig;
     71        estimated[sample-trainingStart] = est;
     72        original[sample-trainingStart] = orig;
    6973        if(orig >= limit) positive++;
    7074        else negative++;
  • trunk/sources/HeuristicLab.StructureIdentification/Evaluation/MeanSquaredErrorEvaluator.cs

    r363 r367  
    4848
    4949    public override double Evaluate(IScope scope, IFunctionTree functionTree, int targetVariable, Dataset dataset) {
    50       double errorsSquaredSum = 0;
    51       double targetMean = dataset.GetMean(targetVariable);
    52       bool useEstimatedValues = GetVariableValue<BoolData>("UseEstimatedTargetValue", scope, false).Data;
    5350      int trainingStart = GetVariableValue<IntData>("TrainingSamplesStart", scope, true).Data;
    5451      int trainingEnd = GetVariableValue<IntData>("TrainingSamplesEnd", scope, true).Data;
     52      double errorsSquaredSum = 0;
     53      double targetMean = dataset.GetMean(targetVariable, trainingStart, trainingEnd);
     54      bool useEstimatedValues = GetVariableValue<BoolData>("UseEstimatedTargetValue", scope, false).Data;
    5555      if(useEstimatedValues && backupValues == null) {
    5656        backupValues = new double[trainingEnd - trainingStart];
  • trunk/sources/HeuristicLab.StructureIdentification/Evaluation/VarianceAccountedForEvaluator.cs

    r363 r367  
    5454
    5555    public override double Evaluate(IScope scope, IFunctionTree functionTree, int targetVariable, Dataset dataset) {
    56       double[] errors = new double[dataset.Rows];
    57       double[] originalTargetVariableValues = new double[dataset.Rows];
    58       double targetMean = dataset.GetMean(targetVariable);
     56      int trainingStart = GetVariableValue<IntData>("TrainingSamplesStart", scope, true).Data;
     57      int trainingEnd = GetVariableValue<IntData>("TrainingSamplesEnd", scope, true).Data;
     58      double[] errors = new double[trainingEnd-trainingStart];
     59      double[] originalTargetVariableValues = new double[trainingEnd-trainingStart];
     60      double targetMean = dataset.GetMean(targetVariable, trainingStart, trainingEnd);
    5961      functionTree.PrepareEvaluation(dataset);
    60       for(int sample = 0; sample < dataset.Rows; sample++) {
     62      for(int sample = trainingStart; sample < trainingEnd; sample++) {
    6163        double estimated = functionTree.Evaluate(sample);
    6264        double original = dataset.GetValue(sample, targetVariable);
     
    7072        }
    7173
    72         errors[sample] = original - estimated;
    73         originalTargetVariableValues[sample] = original;
     74        errors[sample-trainingStart] = original - estimated;
     75        originalTargetVariableValues[sample-trainingStart] = original;
    7476      }
    7577
Note: See TracChangeset for help on using the changeset viewer.