Changeset 1891 for trunk/sources/HeuristicLab.GP.StructureIdentification
- Timestamp:
- 05/25/09 17:46:17 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.GP.StructureIdentification/3.3
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/CoefficientOfDeterminationEvaluator.cs
r1796 r1891 42 42 } 43 43 44 public override void Evaluate(IScope scope, ITreeEvaluator evaluator, IFunctionTree tree,HeuristicLab.DataAnalysis.Dataset dataset, int targetVariable, int start, int end, bool updateTargetValues) {44 public override void Evaluate(IScope scope, ITreeEvaluator evaluator, HeuristicLab.DataAnalysis.Dataset dataset, int targetVariable, int start, int end, bool updateTargetValues) { 45 45 double errorsSquaredSum = 0.0; 46 46 double originalDeviationTotalSumOfSquares = 0.0; … … 50 50 int n = 0; 51 51 for (int sample = start; sample < end; sample++) { 52 double estimated = evaluator.Evaluate( tree,sample);52 double estimated = evaluator.Evaluate(sample); 53 53 double original = dataset.GetValue(sample, targetVariable); 54 54 if (updateTargetValues) { -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/EarlyStoppingMeanSquaredErrorEvaluator.cs
r1796 r1891 44 44 45 45 // evaluates the function-tree for the given target-variable and the whole dataset and returns the MSE 46 public override void Evaluate(IScope scope, ITreeEvaluator evaluator, IFunctionTree tree,HeuristicLab.DataAnalysis.Dataset dataset, int targetVariable, int start, int end, bool updateTargetValues) {46 public override void Evaluate(IScope scope, ITreeEvaluator evaluator, HeuristicLab.DataAnalysis.Dataset dataset, int targetVariable, int start, int end, bool updateTargetValues) { 47 47 double qualityLimit = GetVariableValue<DoubleData>("QualityLimit", scope, false).Data; 48 48 DoubleData mse = GetVariableValue<DoubleData>("MSE", scope, false, false); … … 56 56 int n = 0; 57 57 for (int sample = start; sample < end; sample++) { 58 double estimated = evaluator.Evaluate( tree,sample);58 double estimated = evaluator.Evaluate(sample); 59 59 double original = dataset.GetValue(sample, targetVariable); 60 60 if (updateTargetValues) { -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/GPEvaluatorBase.cs
r1796 r1891 57 57 bool useEstimatedValues = GetVariableValue<BoolData>("UseEstimatedTargetValue", scope, true).Data; 58 58 ITreeEvaluator evaluator = GetVariableValue<ITreeEvaluator>("TreeEvaluator", scope, true); 59 evaluator.PrepareForEvaluation(functionTree); 59 60 60 61 double[] backupValues = null; … … 68 69 } 69 70 70 Evaluate(scope, evaluator, functionTree,dataset, targetVariable, start, end, useEstimatedValues);71 Evaluate(scope, evaluator, dataset, targetVariable, start, end, useEstimatedValues); 71 72 72 73 // restore the values of the target variable from the backup array if necessary … … 82 83 } 83 84 84 public abstract void Evaluate(IScope scope, ITreeEvaluator evaluator, IFunctionTree tree,Dataset dataset, int targetVariable, int start, int end, bool updateTargetValues);85 public abstract void Evaluate(IScope scope, ITreeEvaluator evaluator, Dataset dataset, int targetVariable, int start, int end, bool updateTargetValues); 85 86 } 86 87 } -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/MeanAbsolutePercentageErrorEvaluator.cs
r1796 r1891 43 43 } 44 44 45 public override void Evaluate(IScope scope, ITreeEvaluator evaluator, IFunctionTree tree,Dataset dataset, int targetVariable, int start, int end, bool updateTargetValues) {45 public override void Evaluate(IScope scope, ITreeEvaluator evaluator, Dataset dataset, int targetVariable, int start, int end, bool updateTargetValues) { 46 46 double errorsSum = 0.0; 47 47 int n = 0; 48 48 for (int sample = start; sample < end; sample++) { 49 double estimated = evaluator.Evaluate( tree,sample);49 double estimated = evaluator.Evaluate(sample); 50 50 double original = dataset.GetValue(sample, targetVariable); 51 51 -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/MeanAbsolutePercentageOfRangeErrorEvaluator.cs
r1796 r1891 43 43 } 44 44 45 public override void Evaluate(IScope scope, ITreeEvaluator evaluator, IFunctionTree tree,Dataset dataset, int targetVariable, int start, int end, bool updateTargetValues) {45 public override void Evaluate(IScope scope, ITreeEvaluator evaluator, Dataset dataset, int targetVariable, int start, int end, bool updateTargetValues) { 46 46 double errorsSum = 0.0; 47 47 int n = 0; 48 48 double range = dataset.GetRange(targetVariable, start, end); 49 49 for (int sample = start; sample < end; sample++) { 50 double estimated = evaluator.Evaluate( tree,sample);50 double estimated = evaluator.Evaluate(sample); 51 51 double original = dataset.GetValue(sample, targetVariable); 52 52 -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/MeanSquaredErrorEvaluator.cs
r1796 r1891 43 43 } 44 44 45 public override void Evaluate(IScope scope, ITreeEvaluator evaluator, IFunctionTree tree,Dataset dataset, int targetVariable, int start, int end, bool updateTargetValues) {45 public override void Evaluate(IScope scope, ITreeEvaluator evaluator, Dataset dataset, int targetVariable, int start, int end, bool updateTargetValues) { 46 46 double errorsSquaredSum = 0; 47 47 int n = 0; 48 48 for (int sample = start; sample < end; sample++) { 49 49 double original = dataset.GetValue(sample, targetVariable); 50 double estimated = evaluator.Evaluate( tree,sample);50 double estimated = evaluator.Evaluate(sample); 51 51 if (updateTargetValues) { 52 52 dataset.SetValue(sample, targetVariable, estimated); -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/SimpleEvaluator.cs
r1796 r1891 36 36 } 37 37 38 public override void Evaluate(IScope scope, ITreeEvaluator evaluator, IFunctionTree tree,Dataset dataset, int targetVariable, int start, int end, bool updateTargetValues) {38 public override void Evaluate(IScope scope, ITreeEvaluator evaluator, Dataset dataset, int targetVariable, int start, int end, bool updateTargetValues) { 39 39 ItemList values = GetVariableValue<ItemList>("Values", scope, false, false); 40 40 if (values == null) { … … 50 50 for (int sample = start; sample < end; sample++) { 51 51 ItemList row = new ItemList(); 52 double estimated = evaluator.Evaluate( tree,sample);52 double estimated = evaluator.Evaluate(sample); 53 53 double original = dataset.GetValue(sample, targetVariable); 54 54 if (updateTargetValues) { -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/UncertainMeanSquaredErrorEvaluator.cs
r1796 r1891 50 50 51 51 // evaluates the function-tree for the given target-variable and the whole dataset and returns the MSE 52 public override void Evaluate(IScope scope, ITreeEvaluator evaluator, IFunctionTree tree,HeuristicLab.DataAnalysis.Dataset dataset, int targetVariable, int start, int end, bool updateTargetValues) {52 public override void Evaluate(IScope scope, ITreeEvaluator evaluator, HeuristicLab.DataAnalysis.Dataset dataset, int targetVariable, int start, int end, bool updateTargetValues) { 53 53 double qualityLimit = GetVariableValue<DoubleData>("QualityLimit", scope, false).Data; 54 54 int minSamples = GetVariableValue<IntData>("MinEvaluatedSamples", scope, true).Data; … … 78 78 int n = 0; 79 79 for (int sample = 0; sample < rows; sample++) { 80 double estimated = evaluator.Evaluate( tree,indexes[sample]);80 double estimated = evaluator.Evaluate(indexes[sample]); 81 81 double original = dataset.GetValue(indexes[sample], targetVariable); 82 82 if (!double.IsNaN(original) && !double.IsInfinity(original)) { -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/VarianceAccountedForEvaluator.cs
r1796 r1891 53 53 } 54 54 55 public override void Evaluate(IScope scope, ITreeEvaluator evaluator, IFunctionTree tree,Dataset dataset, int targetVariable, int start, int end, bool updateTargetValues) {55 public override void Evaluate(IScope scope, ITreeEvaluator evaluator, Dataset dataset, int targetVariable, int start, int end, bool updateTargetValues) { 56 56 int nSamples = end - start; 57 57 double[] errors = new double[nSamples]; 58 58 double[] originalTargetVariableValues = new double[nSamples]; 59 59 for (int sample = start; sample < end; sample++) { 60 double estimated = evaluator.Evaluate( tree,sample);60 double estimated = evaluator.Evaluate(sample); 61 61 double original = dataset.GetValue(sample, targetVariable); 62 62 if (updateTargetValues) { -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/ITreeEvaluator.cs
r1796 r1891 32 32 public interface ITreeEvaluator : IItem { 33 33 void ResetEvaluator(Dataset dataset, int targetVariable, int start, int end, double punishmentFactor); 34 double Evaluate(IFunctionTree functionTree, int sampleIndex); 34 void PrepareForEvaluation(IFunctionTree functionTree); 35 double Evaluate(int sampleIndex); 35 36 } 36 37 } -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/TreeEvaluatorBase.cs
r1873 r1891 62 62 } 63 63 64 public void PrepareForEvaluation(IFunctionTree functionTree) { 65 BakedFunctionTree bakedTree = functionTree as BakedFunctionTree; 66 if (bakedTree == null) throw new ArgumentException("TreeEvaluators can only evaluate BakedFunctionTrees"); 67 68 List<LightWeightFunction> linearRepresentation = bakedTree.LinearRepresentation; 69 codeArr = new Instr[linearRepresentation.Count]; 70 int i = 0; 71 foreach (LightWeightFunction f in linearRepresentation) { 72 codeArr[i++] = TranslateToInstr(f); 73 } 74 } 75 64 76 private Instr TranslateToInstr(LightWeightFunction f) { 65 77 Instr instr = new Instr(); … … 86 98 } 87 99 88 public double Evaluate(IFunctionTree functionTree, int sampleIndex) { 89 BakedFunctionTree bakedTree = functionTree as BakedFunctionTree; 90 if (bakedTree == null) throw new ArgumentException("TreeEvaluators can only evaluate BakedFunctionTrees"); 91 92 List<LightWeightFunction> linearRepresentation = bakedTree.LinearRepresentation; 93 codeArr = new Instr[linearRepresentation.Count]; 94 int i = 0; 95 foreach (LightWeightFunction f in linearRepresentation) { 96 codeArr[i++] = TranslateToInstr(f); 97 } 98 100 public double Evaluate(int sampleIndex) { 99 101 PC = 0; 100 102 this.sampleIndex = sampleIndex;
Note: See TracChangeset
for help on using the changeset viewer.