Free cookie consent management tool by TermsFeed Policy Generator

Changeset 5192


Ignore:
Timestamp:
01/02/11 23:48:45 (14 years ago)
Author:
gkronber
Message:

Copied overfitting analyzer for symbolic regression from feature exploration branch. #1356

Location:
trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/HeuristicLab.Problems.DataAnalysis.Regression-3.3.csproj

    r5163 r5192  
    1212    <AssemblyName>HeuristicLab.Problems.DataAnalysis.Regression-3.3</AssemblyName>
    1313    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
    14     <TargetFrameworkProfile></TargetFrameworkProfile>
     14    <TargetFrameworkProfile>
     15    </TargetFrameworkProfile>
    1516    <FileAlignment>512</FileAlignment>
    1617    <SignAssembly>true</SignAssembly>
     
    126127      <SubType>Code</SubType>
    127128    </Compile>
     129    <Compile Include="Symbolic\Analyzers\SymbolicRegressionOverfittingAnalyzer.cs" />
    128130    <Compile Include="Symbolic\Analyzers\SymbolicRegressionSolutionLinearScaler.cs" />
    129131    <Compile Include="Symbolic\Analyzers\SymbolicRegressionVariableFrequencyAnalyzer.cs" />
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/Analyzers/SymbolicRegressionOverfittingAnalyzer.cs

    r5188 r5192  
    3636
    3737namespace HeuristicLab.Problems.DataAnalysis.Regression.Symbolic.Analyzers {
    38   [Item("OverfittingAnalyzer", "")]
     38  [Item("SymbolicRegressionOverfittingAnalyzer", "Calculates and tracks correlation of training and validation fitness of symbolic regression models.")]
    3939  [StorableClass]
    40   public sealed class OverfittingAnalyzer : SingleSuccessorOperator, ISymbolicRegressionAnalyzer {
     40  public sealed class SymbolicRegressionOverfittingAnalyzer : SingleSuccessorOperator, ISymbolicRegressionAnalyzer {
    4141    private const string RandomParameterName = "Random";
    4242    private const string SymbolicExpressionTreeParameterName = "SymbolicExpressionTree";
     43    private const string MaximizationParameterName = "Maximization";
     44    private const string QualityParameterName = "Quality";
     45    private const string ValidationQualityParameterName = "ValidationQuality";
     46    private const string TrainingValidationCorrelationParameterName = "TrainingValidationCorrelation";
     47    private const string TrainingValidationCorrelationTableParameterName = "TrainingValidationCorrelationTable";
     48    private const string LowerCorrelationThresholdParameterName = "LowerCorrelationThreshold";
     49    private const string UpperCorrelationThresholdParameterName = "UpperCorrelationThreshold";
     50    private const string OverfittingParameterName = "IsOverfitting";
     51    private const string ResultsParameterName = "Results";
     52    private const string EvaluatorParameterName = "Evaluator";
    4353    private const string SymbolicExpressionTreeInterpreterParameterName = "SymbolicExpressionTreeInterpreter";
    4454    private const string ProblemDataParameterName = "ProblemData";
    45     private const string ValidationSamplesStartParameterName = "SamplesStart";
    46     private const string ValidationSamplesEndParameterName = "SamplesEnd";
     55    private const string ValidationSamplesStartParameterName = "ValidationSamplesStart";
     56    private const string ValidationSamplesEndParameterName = "ValidationSamplesEnd";
     57    private const string RelativeNumberOfEvaluatedSamplesParameterName = "RelativeNumberOfEvaluatedSamples";
    4758    private const string UpperEstimationLimitParameterName = "UpperEstimationLimit";
    4859    private const string LowerEstimationLimitParameterName = "LowerEstimationLimit";
    49     private const string EvaluatorParameterName = "Evaluator";
    50     private const string MaximizationParameterName = "Maximization";
    51     private const string RelativeNumberOfEvaluatedSamplesParameterName = "RelativeNumberOfEvaluatedSamples";
    5260
    5361    #region parameter properties
     
    5967    }
    6068    public ScopeTreeLookupParameter<DoubleValue> QualityParameter {
    61       get { return (ScopeTreeLookupParameter<DoubleValue>)Parameters["Quality"]; }
     69      get { return (ScopeTreeLookupParameter<DoubleValue>)Parameters[QualityParameterName]; }
    6270    }
    6371    public ScopeTreeLookupParameter<DoubleValue> ValidationQualityParameter {
    64       get { return (ScopeTreeLookupParameter<DoubleValue>)Parameters["ValidationQuality"]; }
     72      get { return (ScopeTreeLookupParameter<DoubleValue>)Parameters[ValidationQualityParameterName]; }
     73    }
     74    public ILookupParameter<BoolValue> MaximizationParameter {
     75      get { return (ILookupParameter<BoolValue>)Parameters[MaximizationParameterName]; }
    6576    }
    6677    public IValueLookupParameter<ISymbolicExpressionTreeInterpreter> SymbolicExpressionTreeInterpreterParameter {
     
    7081      get { return (ILookupParameter<ISymbolicRegressionEvaluator>)Parameters[EvaluatorParameterName]; }
    7182    }
    72     public ILookupParameter<BoolValue> MaximizationParameter {
    73       get { return (ILookupParameter<BoolValue>)Parameters[MaximizationParameterName]; }
    74     }
    7583    public IValueLookupParameter<DataAnalysisProblemData> ProblemDataParameter {
    7684      get { return (IValueLookupParameter<DataAnalysisProblemData>)Parameters[ProblemDataParameterName]; }
     
    8593      get { return (IValueParameter<PercentValue>)Parameters[RelativeNumberOfEvaluatedSamplesParameterName]; }
    8694    }
    87 
    8895    public IValueLookupParameter<DoubleValue> UpperEstimationLimitParameter {
    8996      get { return (IValueLookupParameter<DoubleValue>)Parameters[UpperEstimationLimitParameterName]; }
     
    9299      get { return (IValueLookupParameter<DoubleValue>)Parameters[LowerEstimationLimitParameterName]; }
    93100    }
    94     public ILookupParameter<PercentValue> RelativeValidationQualityParameter {
    95       get { return (ILookupParameter<PercentValue>)Parameters["RelativeValidationQuality"]; }
    96     }
    97     //public IValueLookupParameter<PercentValue> RelativeValidationQualityLowerLimitParameter {
    98     //  get { return (IValueLookupParameter<PercentValue>)Parameters["RelativeValidationQualityLowerLimit"]; }
    99     //}
    100     //public IValueLookupParameter<PercentValue> RelativeValidationQualityUpperLimitParameter {
    101     //  get { return (IValueLookupParameter<PercentValue>)Parameters["RelativeValidationQualityUpperLimit"]; }
    102     //}
    103101    public ILookupParameter<DoubleValue> TrainingValidationQualityCorrelationParameter {
    104       get { return (ILookupParameter<DoubleValue>)Parameters["TrainingValidationCorrelation"]; }
    105     }
    106     public IValueLookupParameter<DoubleValue> LowerCorrelationLimitParameter {
    107       get { return (IValueLookupParameter<DoubleValue>)Parameters["LowerCorrelationLimit"]; }
    108     }
    109     public IValueLookupParameter<DoubleValue> UpperCorrelationLimitParameter {
    110       get { return (IValueLookupParameter<DoubleValue>)Parameters["UpperCorrelationLimit"]; }
     102      get { return (ILookupParameter<DoubleValue>)Parameters[TrainingValidationCorrelationParameterName]; }
     103    }
     104    public ILookupParameter<DataTable> TrainingValidationQualityCorrelationTableParameter {
     105      get { return (ILookupParameter<DataTable>)Parameters[TrainingValidationCorrelationTableParameterName]; }
     106    }
     107    public IValueLookupParameter<DoubleValue> LowerCorrelationThresholdParameter {
     108      get { return (IValueLookupParameter<DoubleValue>)Parameters[LowerCorrelationThresholdParameterName]; }
     109    }
     110    public IValueLookupParameter<DoubleValue> UpperCorrelationThresholdParameter {
     111      get { return (IValueLookupParameter<DoubleValue>)Parameters[UpperCorrelationThresholdParameterName]; }
    111112    }
    112113    public ILookupParameter<BoolValue> OverfittingParameter {
    113       get { return (ILookupParameter<BoolValue>)Parameters["Overfitting"]; }
     114      get { return (ILookupParameter<BoolValue>)Parameters[OverfittingParameterName]; }
    114115    }
    115116    public ILookupParameter<ResultCollection> ResultsParameter {
    116       get { return (ILookupParameter<ResultCollection>)Parameters["Results"]; }
    117     }
    118     public ILookupParameter<DoubleValue> InitialTrainingQualityParameter {
    119       get { return (ILookupParameter<DoubleValue>)Parameters["InitialTrainingQuality"]; }
    120     }
    121     public ILookupParameter<ItemList<DoubleMatrix>> TrainingAndValidationQualitiesParameter {
    122       get { return (ILookupParameter<ItemList<DoubleMatrix>>)Parameters["TrainingAndValidationQualities"]; }
    123     }
    124     public IValueLookupParameter<DoubleValue> PercentileParameter {
    125       get { return (IValueLookupParameter<DoubleValue>)Parameters["Percentile"]; }
     117      get { return (ILookupParameter<ResultCollection>)Parameters[ResultsParameterName]; }
    126118    }
    127119    #endregion
     
    130122      get { return RandomParameter.ActualValue; }
    131123    }
    132     public ItemArray<SymbolicExpressionTree> SymbolicExpressionTree {
    133       get { return SymbolicExpressionTreeParameter.ActualValue; }
     124    public BoolValue Maximization {
     125      get { return MaximizationParameter.ActualValue; }
    134126    }
    135127    public ISymbolicExpressionTreeInterpreter SymbolicExpressionTreeInterpreter {
     
    139131      get { return EvaluatorParameter.ActualValue; }
    140132    }
    141     public BoolValue Maximization {
    142       get { return MaximizationParameter.ActualValue; }
    143     }
    144133    public DataAnalysisProblemData ProblemData {
    145134      get { return ProblemDataParameter.ActualValue; }
     
    163152    #endregion
    164153
    165     public OverfittingAnalyzer()
     154    [StorableConstructor]
     155    private SymbolicRegressionOverfittingAnalyzer(bool deserializing) : base(deserializing) { }
     156    private SymbolicRegressionOverfittingAnalyzer(SymbolicRegressionOverfittingAnalyzer original, Cloner cloner) : base(original, cloner) { }
     157    public SymbolicRegressionOverfittingAnalyzer()
    166158      : base() {
    167       Parameters.Add(new LookupParameter<IRandom>(RandomParameterName, "The random generator to use."));
     159      Parameters.Add(new LookupParameter<IRandom>(RandomParameterName, "The random generator to use."));
     160      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>(QualityParameterName, "Training fitness"));
     161      Parameters.Add(new LookupParameter<BoolValue>(MaximizationParameterName, "The direction of optimization."));
     162
     163      Parameters.Add(new ScopeTreeLookupParameter<SymbolicExpressionTree>(SymbolicExpressionTreeParameterName, "The symbolic expression trees to analyze."));
    168164      Parameters.Add(new LookupParameter<ISymbolicRegressionEvaluator>(EvaluatorParameterName, "The evaluator which should be used to evaluate the solution on the validation set."));
    169       Parameters.Add(new ScopeTreeLookupParameter<SymbolicExpressionTree>(SymbolicExpressionTreeParameterName, "The symbolic expression trees to analyze."));
    170       Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality"));
    171       Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("ValidationQuality"));
    172       Parameters.Add(new LookupParameter<BoolValue>(MaximizationParameterName, "The direction of optimization."));
    173165      Parameters.Add(new ValueLookupParameter<ISymbolicExpressionTreeInterpreter>(SymbolicExpressionTreeInterpreterParameterName, "The interpreter that should be used for the analysis of symbolic expression trees."));
    174166      Parameters.Add(new ValueLookupParameter<DataAnalysisProblemData>(ProblemDataParameterName, "The problem data for which the symbolic expression tree is a solution."));
     
    178170      Parameters.Add(new ValueLookupParameter<DoubleValue>(UpperEstimationLimitParameterName, "The upper estimation limit that was set for the evaluation of the symbolic expression trees."));
    179171      Parameters.Add(new ValueLookupParameter<DoubleValue>(LowerEstimationLimitParameterName, "The lower estimation limit that was set for the evaluation of the symbolic expression trees."));
    180       Parameters.Add(new LookupParameter<PercentValue>("RelativeValidationQuality"));
    181       //Parameters.Add(new ValueLookupParameter<PercentValue>("RelativeValidationQualityUpperLimit", new PercentValue(0.05)));
    182       //Parameters.Add(new ValueLookupParameter<PercentValue>("RelativeValidationQualityLowerLimit", new PercentValue(-0.05)));
    183       Parameters.Add(new LookupParameter<DoubleValue>("TrainingValidationCorrelation"));
    184       Parameters.Add(new ValueLookupParameter<DoubleValue>("LowerCorrelationLimit", new DoubleValue(0.65)));
    185       Parameters.Add(new ValueLookupParameter<DoubleValue>("UpperCorrelationLimit", new DoubleValue(0.75)));
    186       Parameters.Add(new LookupParameter<BoolValue>("Overfitting"));
    187       Parameters.Add(new LookupParameter<ResultCollection>("Results"));
    188       Parameters.Add(new LookupParameter<DoubleValue>("InitialTrainingQuality"));
    189       Parameters.Add(new LookupParameter<ItemList<DoubleMatrix>>("TrainingAndValidationQualities"));
    190       Parameters.Add(new ValueLookupParameter<DoubleValue>("Percentile", new DoubleValue(1)));
    191 
    192     }
    193 
    194     [StorableConstructor]
    195     private OverfittingAnalyzer(bool deserializing) : base(deserializing) { }
     172
     173      Parameters.Add(new LookupParameter<DoubleValue>(TrainingValidationCorrelationParameterName, "Correlation of training and validation fitnesses"));
     174      Parameters.Add(new LookupParameter<DataTable>(TrainingValidationCorrelationTableParameterName, "Data table of training and validation fitness correlation values over the whole run."));
     175      Parameters.Add(new ValueLookupParameter<DoubleValue>(LowerCorrelationThresholdParameterName, "Lower threshold for correlation value that marks the boundary from non-overfitting to overfitting.", new DoubleValue(0.65)));
     176      Parameters.Add(new ValueLookupParameter<DoubleValue>(UpperCorrelationThresholdParameterName, "Upper threshold for correlation value that marks the boundary from overfitting to non-overfitting.", new DoubleValue(0.75)));
     177      Parameters.Add(new LookupParameter<BoolValue>(OverfittingParameterName, "Boolean indicator for overfitting."));
     178      Parameters.Add(new LookupParameter<ResultCollection>(ResultsParameterName, "The results collection."));
     179    }
    196180
    197181    [StorableHook(HookType.AfterDeserialization)]
    198182    private void AfterDeserialization() {
    199       if (!Parameters.ContainsKey("InitialTrainingQuality")) {
    200         Parameters.Add(new LookupParameter<DoubleValue>("InitialTrainingQuality"));
     183    }
     184
     185    public override IDeepCloneable Clone(Cloner cloner) {
     186      return new SymbolicRegressionOverfittingAnalyzer(this, cloner);
     187    }
     188
     189    public override IOperation Apply() {
     190      ItemArray<DoubleValue> qualities = QualityParameter.ActualValue;
     191      double[] trainingArr = qualities.Select(x => x.Value).ToArray();
     192      double[] validationArr = new double[trainingArr.Length];
     193
     194      #region calculate validation fitness
     195      string targetVariable = ProblemData.TargetVariable.Value;
     196
     197      // select a random subset of rows in the validation set
     198      int validationStart = ValidiationSamplesStart.Value;
     199      int validationEnd = ValidationSamplesEnd.Value;
     200      int seed = Random.Next();
     201      int count = (int)((validationEnd - validationStart) * RelativeNumberOfEvaluatedSamples.Value);
     202      if (count == 0) count = 1;
     203      IEnumerable<int> rows = RandomEnumerable.SampleRandomNumbers(seed, validationStart, validationEnd, count)
     204        .Where(row => row < ProblemData.TestSamplesStart.Value || ProblemData.TestSamplesEnd.Value <= row);
     205
     206      double upperEstimationLimit = UpperEstimationLimit != null ? UpperEstimationLimit.Value : double.PositiveInfinity;
     207      double lowerEstimationLimit = LowerEstimationLimit != null ? LowerEstimationLimit.Value : double.NegativeInfinity;
     208
     209      var trees = SymbolicExpressionTreeParameter.ActualValue;
     210
     211      for (int i = 0; i < validationArr.Length; i++) {
     212        var tree = trees[i];
     213        double quality = Evaluator.Evaluate(SymbolicExpressionTreeInterpreter, tree,
     214            lowerEstimationLimit, upperEstimationLimit,
     215            ProblemData.Dataset, targetVariable,
     216           rows);
     217        validationArr[i] = quality;
    201218      }
    202       //if (!Parameters.ContainsKey("RelativeValidationQualityUpperLimit")) {
    203       //  Parameters.Add(new ValueLookupParameter<PercentValue>("RelativeValidationQualityUpperLimit", new PercentValue(0.05)));
    204       //}
    205       //if (!Parameters.ContainsKey("RelativeValidationQualityLowerLimit")) {
    206       //  Parameters.Add(new ValueLookupParameter<PercentValue>("RelativeValidationQualityLowerLimit", new PercentValue(-0.05)));
    207       //}
    208       if (!Parameters.ContainsKey("TrainingAndValidationQualities")) {
    209         Parameters.Add(new LookupParameter<ItemList<DoubleMatrix>>("TrainingAndValidationQualities"));
     219     
     220      #endregion
     221
     222
     223      double r = alglib.spearmancorr2(trainingArr, validationArr);
     224
     225      TrainingValidationQualityCorrelationParameter.ActualValue = new DoubleValue(r);
     226
     227      if (TrainingValidationQualityCorrelationTableParameter.ActualValue == null) {
     228        var dataTable = new DataTable("Training and validation fitness correlation table", "Data table of training and validation fitness correlation values over the whole run.");
     229        dataTable.Rows.Add(new DataRow("Training and validation fitness correlation", "Training and validation fitness correlation values"));
     230        TrainingValidationQualityCorrelationTableParameter.ActualValue = dataTable;
     231        ResultsParameter.ActualValue.Add(new Result(TrainingValidationCorrelationTableParameterName, dataTable));
    210232      }
    211       if (!Parameters.ContainsKey("Percentile")) {
    212         Parameters.Add(new ValueLookupParameter<DoubleValue>("Percentile", new DoubleValue(1)));
     233
     234      TrainingValidationQualityCorrelationTableParameter.ActualValue.Rows["Training and validation fitness correlation"].Values.Add(r);
     235
     236      double correlationThreshold;
     237      if (OverfittingParameter.ActualValue != null && OverfittingParameter.ActualValue.Value) {
     238        // if is already overfitting => have to reach the upper threshold to switch back to non-overfitting state
     239        correlationThreshold = UpperCorrelationThresholdParameter.ActualValue.Value;
     240      } else {
     241        // if currently in non-overfitting state => have to reach to lower threshold to switch to overfitting state
     242        correlationThreshold = LowerCorrelationThresholdParameter.ActualValue.Value;
    213243      }
    214       if (!Parameters.ContainsKey("ValidationQuality")) {
    215         Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("ValidationQuality"));
    216       }
    217       if (!Parameters.ContainsKey("LowerCorrelationLimit")) {
    218         Parameters.Add(new ValueLookupParameter<DoubleValue>("LowerCorrelationLimit", new DoubleValue(0.65)));
    219       }
    220       if (!Parameters.ContainsKey("UpperCorrelationLimit")) {
    221         Parameters.Add(new ValueLookupParameter<DoubleValue>("UpperCorrelationLimit", new DoubleValue(0.75)));
    222       }
    223 
    224     }
    225 
    226     public override IOperation Apply() {
    227       var trees = SymbolicExpressionTree;
    228       ItemArray<DoubleValue> qualities = QualityParameter.ActualValue;
    229       ItemArray<DoubleValue> validationQualities = ValidationQualityParameter.ActualValue;
    230 
    231       double correlationLimit;
    232       if (OverfittingParameter.ActualValue != null && OverfittingParameter.ActualValue.Value) {
    233         // if is already overfitting have to reach the upper limit to switch back to non-overfitting state
    234         correlationLimit = UpperCorrelationLimitParameter.ActualValue.Value;
    235       } else {
    236         // if currently in non-overfitting state have to reach to lower limit to switch to overfitting state
    237         correlationLimit = LowerCorrelationLimitParameter.ActualValue.Value;
    238       }
    239       //string targetVariable = ProblemData.TargetVariable.Value;
    240 
    241       //// select a random subset of rows in the validation set
    242       //int validationStart = ValidiationSamplesStart.Value;
    243       //int validationEnd = ValidationSamplesEnd.Value;
    244       //int seed = Random.Next();
    245       //int count = (int)((validationEnd - validationStart) * RelativeNumberOfEvaluatedSamples.Value);
    246       //if (count == 0) count = 1;
    247       //IEnumerable<int> rows = RandomEnumerable.SampleRandomNumbers(seed, validationStart, validationEnd, count);
    248 
    249       //double upperEstimationLimit = UpperEstimationLimit != null ? UpperEstimationLimit.Value : double.PositiveInfinity;
    250       //double lowerEstimationLimit = LowerEstimationLimit != null ? LowerEstimationLimit.Value : double.NegativeInfinity;
    251 
    252       //double bestQuality = Maximization.Value ? double.NegativeInfinity : double.PositiveInfinity;
    253       //SymbolicExpressionTree bestTree = null;
    254 
    255       //List<double> validationQualities = new List<double>();
    256       //foreach (var tree in trees) {
    257       //  double quality = Evaluator.Evaluate(SymbolicExpressionTreeInterpreter, tree,
    258       //    lowerEstimationLimit, upperEstimationLimit,
    259       //    ProblemData.Dataset, targetVariable,
    260       //   rows);
    261       //  validationQualities.Add(quality);
    262       //  //if ((Maximization.Value && quality > bestQuality) ||
    263       //  //    (!Maximization.Value && quality < bestQuality)) {
    264       //  //  bestQuality = quality;
    265       //  //  bestTree = tree;
    266       //  //}
    267       //}
    268 
    269       //if (RelativeValidationQualityParameter.ActualValue == null) {
    270       // first call initialize the relative quality using the difference between average training and validation quality
    271       double avgTrainingQuality = qualities.Select(x => x.Value).Average();
    272       double avgValidationQuality = validationQualities.Select(x => x.Value).Average();
    273 
    274       if (Maximization.Value)
    275         RelativeValidationQualityParameter.ActualValue = new PercentValue(avgValidationQuality / avgTrainingQuality - 1);
    276       else {
    277         RelativeValidationQualityParameter.ActualValue = new PercentValue(avgTrainingQuality / avgValidationQuality - 1);
    278       }
    279       //}
    280 
    281       // best first (only for maximization
    282       var orderedDistinctPairs = (from index in Enumerable.Range(0, qualities.Length)
    283                                   where qualities[index].Value > 0.0
    284                                   select new { Training = qualities[index].Value, Validation = validationQualities[index].Value })
    285                                  .OrderBy(x => -x.Training)
    286                                  .ToList();
    287 
    288       int n = (int)Math.Round(PercentileParameter.ActualValue.Value * orderedDistinctPairs.Count);
    289 
    290       double[] validationArr = new double[n];
    291       double[] trainingArr = new double[n];
    292       double[,] qualitiesArr = new double[n, 2];
    293       for (int i = 0; i < n; i++) {
    294         validationArr[i] = orderedDistinctPairs[i].Validation;
    295         trainingArr[i] = orderedDistinctPairs[i].Training;
    296 
    297         qualitiesArr[i, 0] = trainingArr[i];
    298         qualitiesArr[i, 1] = validationArr[i];
    299       }
    300       double r = alglib.correlation.spearmanrankcorrelation(trainingArr, validationArr, n);
    301       TrainingValidationQualityCorrelationParameter.ActualValue = new DoubleValue(r);
    302       if (InitialTrainingQualityParameter.ActualValue == null)
    303         InitialTrainingQualityParameter.ActualValue = new DoubleValue(avgValidationQuality);
    304       bool overfitting =
    305         avgTrainingQuality > InitialTrainingQualityParameter.ActualValue.Value &&  // better on training than in initial generation
    306         // RelativeValidationQualityParameter.ActualValue.Value < 0.0 && // validation quality is worse than training quality
    307         r < correlationLimit;
    308 
     244      bool overfitting = r < correlationThreshold;
    309245
    310246      OverfittingParameter.ActualValue = new BoolValue(overfitting);
    311       ItemList<DoubleMatrix> list = TrainingAndValidationQualitiesParameter.ActualValue;
    312       if (list == null) {
    313         TrainingAndValidationQualitiesParameter.ActualValue = new ItemList<DoubleMatrix>();
    314       }
    315       TrainingAndValidationQualitiesParameter.ActualValue.Add(new DoubleMatrix(qualitiesArr));
     247
    316248      return base.Apply();
    317     }
    318 
    319     [StorableHook(HookType.AfterDeserialization)]
    320     private void Initialize() { }
    321 
    322     private static void AddValue(DataTable table, double data, string name, string description) {
    323       DataRow row;
    324       table.Rows.TryGetValue(name, out row);
    325       if (row == null) {
    326         row = new DataRow(name, description);
    327         row.Values.Add(data);
    328         table.Rows.Add(row);
    329       } else {
    330         row.Values.Add(data);
    331       }
    332249    }
    333250  }
Note: See TracChangeset for help on using the changeset viewer.