- Timestamp:
- 01/01/10 19:06:18 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/EarlyStoppingMeanSquaredErrorEvaluator.cs
r2222 r2577 39 39 40 40 // evaluates the function-tree for the given target-variable and the whole dataset and returns the MSE 41 public override void Evaluate(IScope scope, ITreeEvaluator evaluator, HeuristicLab.DataAnalysis.Dataset dataset, int targetVariable, int start, int end , bool updateTargetValues) {41 public override void Evaluate(IScope scope, ITreeEvaluator evaluator, HeuristicLab.DataAnalysis.Dataset dataset, int targetVariable, int start, int end) { 42 42 double qualityLimit = GetVariableValue<DoubleData>("QualityLimit", scope, true).Data; 43 43 DoubleData mse = GetVariableValue<DoubleData>("MSE", scope, false, false); … … 53 53 double estimated = evaluator.Evaluate(sample); 54 54 double original = dataset.GetValue(sample, targetVariable); 55 if (updateTargetValues) { 56 dataset.SetValue(sample, targetVariable, estimated); 57 } 55 58 56 if (!double.IsNaN(original) && !double.IsInfinity(original)) { 59 57 double error = estimated - original; -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/GPEvaluatorBase.cs
r2440 r2577 36 36 AddVariableInfo(new VariableInfo("SamplesStart", "Start index of samples in dataset to evaluate", typeof(IntData), VariableKind.In)); 37 37 AddVariableInfo(new VariableInfo("SamplesEnd", "End index of samples in dataset to evaluate", typeof(IntData), VariableKind.In)); 38 AddVariableInfo(new VariableInfo("UseEstimatedTargetValue", "(optional) Wether to use the original (measured) or the estimated (calculated) value for the target variable for autoregressive modelling", typeof(BoolData), VariableKind.In));39 38 } 40 39 … … 47 46 int start = GetVariableValue<IntData>("SamplesStart", scope, true).Data; 48 47 int end = GetVariableValue<IntData>("SamplesEnd", scope, true).Data; 49 BoolData useEstimatedValuesData = GetVariableValue<BoolData>("UseEstimatedTargetValue", scope, true, false);50 bool useEstimatedValues = useEstimatedValuesData == null ? false : useEstimatedValuesData.Data;51 48 ITreeEvaluator evaluator = GetVariableValue<ITreeEvaluator>("TreeEvaluator", scope, true); 49 52 50 evaluator.PrepareForEvaluation(dataset, gpModel.FunctionTree); 53 54 double[] backupValues = null; 55 // prepare for autoregressive modelling by saving the original values of the target-variable to a backup array 56 if (useEstimatedValues && 57 (backupValues == null || backupValues.Length != end - start)) { 58 backupValues = new double[end - start]; 59 for (int i = start; i < end; i++) { 60 backupValues[i - start] = dataset.GetValue(i, targetVariable); 61 } 62 } 63 dataset.FireChangeEvents = false; 64 65 Evaluate(scope, evaluator, dataset, targetVariable, start, end, useEstimatedValues); 66 67 // restore the values of the target variable from the backup array if necessary 68 if (useEstimatedValues) { 69 for (int i = start; i < end; i++) { 70 dataset.SetValue(i, targetVariable, backupValues[i - start]); 71 } 72 } 73 dataset.FireChangeEvents = true; 74 dataset.FireChanged(); 51 Evaluate(scope, evaluator, dataset, targetVariable, start, end); 75 52 76 53 // update the value of total evaluated nodes … … 79 56 } 80 57 81 public abstract void Evaluate(IScope scope, ITreeEvaluator evaluator, Dataset dataset, int targetVariable, int start, int end , bool updateTargetValues);58 public abstract void Evaluate(IScope scope, ITreeEvaluator evaluator, Dataset dataset, int targetVariable, int start, int end); 82 59 } 83 60 } -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/SimpleEvaluator.cs
r2222 r2577 31 31 } 32 32 33 public override void Evaluate(IScope scope, ITreeEvaluator evaluator, Dataset dataset, int targetVariable, int start, int end , bool updateTargetValues) {33 public override void Evaluate(IScope scope, ITreeEvaluator evaluator, Dataset dataset, int targetVariable, int start, int end) { 34 34 DoubleMatrixData values = GetVariableValue<DoubleMatrixData>("Values", scope, false, false); 35 35 if (values == null) { … … 47 47 double estimated = evaluator.Evaluate(sample); 48 48 double original = dataset.GetValue(sample, targetVariable); 49 if (updateTargetValues) { 50 dataset.SetValue(sample, targetVariable, estimated); 51 } 49 52 50 v[sample - start, 0] = original; 53 51 v[sample - start, 1] = estimated; -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/SimpleGPEvaluatorBase.cs
r2222 r2577 33 33 } 34 34 35 public override void Evaluate(IScope scope, ITreeEvaluator evaluator, Dataset dataset, int targetVariable, int start, int end , bool updateTargetValues) {35 public override void Evaluate(IScope scope, ITreeEvaluator evaluator, Dataset dataset, int targetVariable, int start, int end) { 36 36 // store original and estimated values in a double array 37 37 double[,] values = new double[end - start, 2]; … … 39 39 double original = dataset.GetValue(sample, targetVariable); 40 40 double estimated = evaluator.Evaluate(sample); 41 if (updateTargetValues) { 42 dataset.SetValue(sample, targetVariable, estimated); 43 } 41 44 42 values[sample - start, 0] = estimated; 45 43 values[sample - start, 1] = original; -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/UncertainMeanSquaredErrorEvaluator.cs
r2222 r2577 45 45 46 46 // evaluates the function-tree for the given target-variable and the whole dataset and returns the MSE 47 public override void Evaluate(IScope scope, ITreeEvaluator evaluator, HeuristicLab.DataAnalysis.Dataset dataset, int targetVariable, int start, int end , bool updateTargetValues) {47 public override void Evaluate(IScope scope, ITreeEvaluator evaluator, HeuristicLab.DataAnalysis.Dataset dataset, int targetVariable, int start, int end) { 48 48 double qualityLimit = GetVariableValue<DoubleData>("QualityLimit", scope, true).Data; 49 49 int minSamples = GetVariableValue<IntData>("MinEvaluatedSamples", scope, true).Data;
Note: See TracChangeset
for help on using the changeset viewer.