Free cookie consent management tool by TermsFeed Policy Generator

Changeset 14301


Ignore:
Timestamp:
09/22/16 17:00:29 (8 years ago)
Author:
bburlacu
Message:

#2635: Use linear scaling in the evaluator to bring the target in the range of the estimated (work in progress)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.OSGAEvaluator/HeuristicLab.OSGAEvaluator/SymbolicRegressionSingleObjectiveOSGAEvaluator.cs

    r14281 r14301  
    292292        #endregion
    293293      } else {
    294         var calculator = new OnlinePearsonsRCalculator();
    295294        var trainingPartitionSize = problemData.TrainingPartition.Size;
    296295        var interval = (int)Math.Floor(trainingPartitionSize * RelativeFitnessEvaluationIntervalSize);
     
    299298        // use the actual estimated values for the first i * interval rows of the training partition and and assume the remaining rows are perfectly correlated
    300299        // if the quality of the individual still falls below the parent quality, then we can reject it sooner, otherwise as i increases the whole estimated series will be used
     300        var lsc = new OnlineLinearScalingParameterCalculator();
     301        var rcalc = new OnlinePearsonsRCalculator();
     302        var actualQuality = SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, SymbolicExpressionTreeParameter.ActualValue, estimationLimits.Lower, estimationLimits.Upper, problemData, problemData.TrainingIndices, false);
    301303        for (int i = 0; i < trainingPartitionSize; i += interval) {
    302           calculator.Reset();
    303           // save estimated values into the list (for caching)
     304          var start = problemData.TrainingPartition.Start;
    304305          int end = Math.Min(trainingPartitionSize, i + interval);
     306          // cache estimated values
     307          // scale target values to the range of the estimated values
    305308          for (int j = i; j < end && e.MoveNext(); ++j) {
    306309            estimated.Add(e.Current);
    307           }
    308           var start = problemData.TrainingPartition.Start;
    309           // add (estimated, target) pairs to the calculator
    310           for (int j = 0; j < end; ++j) {
    311310            var index = j + start;
    312             calculator.Add(targetValues[index], estimated[j]);
    313           }
    314           // add (target, target) pairs to the calculator (simulate perfect correlation on the remaining rows)
     311            // in the context of the linear scaling calculator, the target value becomes the "original"
     312            // while the estimated value becomes the "target" (because we want to scale the target in the range of the estimated)
     313            lsc.Add(targetValues[index], e.Current);
     314          }
     315          var a = lsc.Alpha; // additive scaling term
     316          var b = lsc.Beta;  // multiplicative scaling factor
     317          // calculate the quality
     318          for (int j = i; j < end; ++j) {
     319            var index = j + start;
     320            rcalc.Add(estimated[j], targetValues[index]);
     321          }
     322          var rcalc2 = (OnlinePearsonsRCalculator)rcalc.Clone();
    315323          for (int j = end; j < trainingPartitionSize; ++j) {
    316324            var index = j + start;
    317             var v = targetValues[index];
    318             calculator.Add(v, v);
    319           }
    320           var r = calculator.ErrorState == OnlineCalculatorError.None ? calculator.R : double.NaN;
     325            var v = targetValues[index] * b + a;
     326            rcalc2.Add(v, targetValues[index]);
     327          }
     328          var r = rcalc2.ErrorState == OnlineCalculatorError.None ? rcalc2.R : double.NaN;
    321329          quality = r * r;
    322           if (!(quality > parentQuality))
    323             break;
     330          bool falseReject = false;
     331          if (!(quality > parentQuality)) {
     332            if (actualQuality > parentQuality)
     333              falseReject = true;
     334          }
     335          //          if (!(quality > parentQuality))
     336          //            break;
    324337        }
     338
    325339        return quality;
    326340      }
Note: See TracChangeset for help on using the changeset viewer.