Changeset 1891
- Timestamp:
- 05/25/09 17:46:17 (16 years ago)
- Location:
- trunk/sources
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/AccuracyEvaluator.cs
r1796 r1891 43 43 } 44 44 45 public override void Evaluate(IScope scope, ITreeEvaluator evaluator, IFunctionTree tree,Dataset dataset, int targetVariable, double[] classes, double[] thresholds, int start, int end) {45 public override void Evaluate(IScope scope, ITreeEvaluator evaluator, Dataset dataset, int targetVariable, double[] classes, double[] thresholds, int start, int end) { 46 46 DoubleData accuracy = GetVariableValue<DoubleData>("Accuracy", scope, false, false); 47 47 if (accuracy == null) { … … 53 53 int nCorrect = 0; 54 54 for (int sample = start; sample < end; sample++) { 55 double est = evaluator.Evaluate( tree,sample);55 double est = evaluator.Evaluate(sample); 56 56 double origClass = dataset.GetValue(sample, targetVariable); 57 57 double estClass = double.NaN; -
trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/ClassificationMeanSquaredErrorEvaluator.cs
r1796 r1891 43 43 } 44 44 45 public override void Evaluate(IScope scope, ITreeEvaluator evaluator, IFunctionTree tree,HeuristicLab.DataAnalysis.Dataset dataset, int targetVariable, double[] classes, double[] thresholds, int start, int end) {45 public override void Evaluate(IScope scope, ITreeEvaluator evaluator, HeuristicLab.DataAnalysis.Dataset dataset, int targetVariable, double[] classes, double[] thresholds, int start, int end) { 46 46 double errorsSquaredSum = 0; 47 47 for (int sample = start; sample < end; sample++) { 48 double estimated = evaluator.Evaluate( tree,sample);48 double estimated = evaluator.Evaluate(sample); 49 49 double original = dataset.GetValue(sample, targetVariable); 50 50 if (!double.IsNaN(original) && !double.IsInfinity(original)) { -
trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/ConfusionMatrixEvaluator.cs
r1796 r1891 41 41 } 42 42 43 public override void Evaluate(IScope scope, ITreeEvaluator evaluator, IFunctionTree tree,HeuristicLab.DataAnalysis.Dataset dataset, int targetVariable, double[] classes, double[] thresholds, int start, int end) {43 public override void Evaluate(IScope scope, ITreeEvaluator evaluator, HeuristicLab.DataAnalysis.Dataset dataset, int targetVariable, double[] classes, double[] thresholds, int start, int end) { 44 44 IntMatrixData matrix = GetVariableValue<IntMatrixData>("ConfusionMatrix", scope, false, false); 45 45 if (matrix == null) { … … 50 50 int nSamples = end - start; 51 51 for (int sample = start; sample < end; sample++) { 52 double est = evaluator.Evaluate( tree,sample);52 double est = evaluator.Evaluate(sample); 53 53 double origClass = dataset.GetValue(sample, targetVariable); 54 54 int estClassIndex = -1; -
trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/GPClassificationEvaluatorBase.cs
r1796 r1891 37 37 } 38 38 39 public override void Evaluate(IScope scope, ITreeEvaluator evaluator, IFunctionTree tree,Dataset dataset, int targetVariable, int start, int end, bool updateTargetValues) {39 public override void Evaluate(IScope scope, ITreeEvaluator evaluator, Dataset dataset, int targetVariable, int start, int end, bool updateTargetValues) { 40 40 41 41 ItemList<DoubleData> classes = GetVariableValue<ItemList<DoubleData>>("TargetClassValues", scope, true); … … 48 48 } 49 49 50 Evaluate(scope, evaluator, tree,dataset, targetVariable, classesArr, thresholds, start, end);50 Evaluate(scope, evaluator, dataset, targetVariable, classesArr, thresholds, start, end); 51 51 } 52 52 53 public abstract void Evaluate(IScope scope, ITreeEvaluator evaluator, IFunctionTree tree,Dataset dataset, int targetVariable, double[] classes, double[] thresholds, int start, int end);53 public abstract void Evaluate(IScope scope, ITreeEvaluator evaluator, Dataset dataset, int targetVariable, double[] classes, double[] thresholds, int start, int end); 54 54 } 55 55 } -
trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/MulticlassOneVsOneAnalyzer.cs
r1796 r1891 86 86 BakedTreeEvaluator evaluator = new BakedTreeEvaluator(); 87 87 evaluator.ResetEvaluator(dataset, targetVariable, trainingSamplesStart, trainingSamplesEnd, 1.0); 88 88 evaluator.PrepareForEvaluation(functionTree); 89 89 for(int i = 0; i < (samplesEnd - samplesStart); i++) { 90 double est = evaluator.Evaluate( functionTree,i + samplesStart);90 double est = evaluator.Evaluate(i + samplesStart); 91 91 if(est < 0.5) { 92 92 CastVote(votes, i, classAValue, classValues); -
trunk/sources/HeuristicLab.GP.StructureIdentification.TimeSeries/3.3/AveragePercentageChangeEvaluator.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 bool differential = GetVariableValue<BoolData>("Differential", scope, true).Data; 46 46 DoubleData apc = GetVariableValue<DoubleData>("APC", scope, false, false); … … 58 58 prevOriginal = dataset.GetValue(sample - 1, targetVariable); 59 59 originalPercentageChange = (dataset.GetValue(sample, targetVariable) - prevOriginal) / prevOriginal; 60 estimatedPercentageChange = (evaluator.Evaluate( tree,sample) - prevOriginal) / prevOriginal;60 estimatedPercentageChange = (evaluator.Evaluate(sample) - prevOriginal) / prevOriginal; 61 61 if (updateTargetValues) { 62 62 dataset.SetValue(sample, targetVariable, estimatedPercentageChange * prevOriginal + prevOriginal); … … 64 64 } else { 65 65 originalPercentageChange = dataset.GetValue(sample, targetVariable); 66 estimatedPercentageChange = evaluator.Evaluate( tree,sample);66 estimatedPercentageChange = evaluator.Evaluate(sample); 67 67 if (updateTargetValues) { 68 68 dataset.SetValue(sample, targetVariable, estimatedPercentageChange); -
trunk/sources/HeuristicLab.GP.StructureIdentification.TimeSeries/3.3/ProfitEvaluator.cs
r1796 r1891 43 43 } 44 44 45 public override void Evaluate(IScope scope, ITreeEvaluator evaluator, IFunctionTree tree,HeuristicLab.DataAnalysis.Dataset dataset, int targetVariable, int start, int end, bool updateTargetValues) {45 public override void Evaluate(IScope scope, ITreeEvaluator evaluator, HeuristicLab.DataAnalysis.Dataset dataset, int targetVariable, int start, int end, bool updateTargetValues) { 46 46 int exchangeRateVarIndex = GetVariableValue<IntData>("ExchangeRate", scope, true).Data; 47 47 double transactionCost = GetVariableValue<DoubleData>("TransactionCost", scope, true).Data; … … 58 58 exchangeRate = dataset.GetValue(sample, exchangeRateVarIndex); 59 59 double originalPercentageChange = dataset.GetValue(sample, targetVariable); 60 double estimatedPercentageChange = evaluator.Evaluate( tree,sample);60 double estimatedPercentageChange = evaluator.Evaluate(sample); 61 61 if (updateTargetValues) { 62 62 dataset.SetValue(sample, targetVariable, estimatedPercentageChange); -
trunk/sources/HeuristicLab.GP.StructureIdentification.TimeSeries/3.3/TheilInequalityCoefficientEvaluator.cs
r1796 r1891 54 54 } 55 55 56 public override void Evaluate(IScope scope, ITreeEvaluator evaluator, IFunctionTree tree,Dataset dataset, int targetVariable, int start, int end, bool updateTargetValues) {56 public override void Evaluate(IScope scope, ITreeEvaluator evaluator, Dataset dataset, int targetVariable, int start, int end, bool updateTargetValues) { 57 57 #region create result variables 58 58 DoubleData theilInequaliy = GetVariableValue<DoubleData>("TheilInequalityCoefficient", scope, false, false); … … 85 85 for (int sample = start; sample < end; sample++) { 86 86 double prevValue = dataset.GetValue(sample - 1, targetVariable); 87 double estimatedChange = evaluator.Evaluate( tree,sample) - prevValue;87 double estimatedChange = evaluator.Evaluate(sample) - prevValue; 88 88 double originalChange = dataset.GetValue(sample, targetVariable) - prevValue; 89 89 if (updateTargetValues) { -
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.