Changeset 2577 for trunk/sources
- Timestamp:
- 01/01/10 19:06:18 (15 years ago)
- Location:
- trunk/sources
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/GPClassificationEvaluatorBase.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 37 37 ItemList<DoubleData> classes = GetVariableValue<ItemList<DoubleData>>("TargetClassValues", scope, true); -
trunk/sources/HeuristicLab.GP.StructureIdentification.ConditionalEvaluation/3.3/ConditionalEvaluatorBase.cs
r1926 r2577 40 40 } 41 41 42 public override void Evaluate(IScope scope, ITreeEvaluator evaluator, Dataset dataset, int targetVariable, int start, int end , bool updateTargetValues) {42 public override void Evaluate(IScope scope, ITreeEvaluator evaluator, Dataset dataset, int targetVariable, int start, int end) { 43 43 int maxTimeOffset = GetVariableValue<IntData>("MaxTimeOffset", scope, true).Data; 44 44 int minTimeOffset = GetVariableValue<IntData>("MinTimeOffset", scope, true).Data; … … 60 60 double original = dataset.GetValue(sample, targetVariable); 61 61 double estimated = evaluator.Evaluate(sample); 62 if (updateTargetValues) { 63 dataset.SetValue(sample, targetVariable, estimated); 64 } 62 65 63 values[sample - start - skippedSampels, 0] = estimated; 66 64 values[sample - start - skippedSampels, 1] = original; 67 65 } 68 66 } 69 //needed because otherwise the array is too large d dimension and therefore the sample count is falseduring calculation67 //needed because otherwise the array is too large and therefore the sample count is incorrect during calculation 70 68 ResizeArray(ref values, 2, end - start - skippedSampels); 71 69 -
trunk/sources/HeuristicLab.GP.StructureIdentification.ConditionalEvaluation/3.3/ConditionalSimpleEvaluator.cs
r1916 r2577 38 38 } 39 39 40 public override void Evaluate(IScope scope, ITreeEvaluator evaluator, Dataset dataset, int targetVariable, int start, int end , bool updateTargetValues) {40 public override void Evaluate(IScope scope, ITreeEvaluator evaluator, Dataset dataset, int targetVariable, int start, int end) { 41 41 ItemList values = GetVariableValue<ItemList>("Values", scope, false, false); 42 42 if (values == null) { … … 68 68 double estimated = evaluator.Evaluate(sample); 69 69 double original = dataset.GetValue(sample, targetVariable); 70 if (updateTargetValues) { 71 dataset.SetValue(sample, targetVariable, estimated); 72 } 70 73 71 row.Add(new DoubleData(estimated)); 74 72 row.Add(new DoubleData(original)); -
trunk/sources/HeuristicLab.GP.StructureIdentification.TimeSeries/3.3/AveragePercentageChangeEvaluator.cs
r2222 r2577 38 38 } 39 39 40 public override void Evaluate(IScope scope, ITreeEvaluator evaluator, HeuristicLab.DataAnalysis.Dataset dataset, int targetVariable, int start, int end , bool updateTargetValues) {40 public override void Evaluate(IScope scope, ITreeEvaluator evaluator, HeuristicLab.DataAnalysis.Dataset dataset, int targetVariable, int start, int end) { 41 41 bool differential = GetVariableValue<BoolData>("Differential", scope, true).Data; 42 42 DoubleData apc = GetVariableValue<DoubleData>("APC", scope, false, false); … … 55 55 originalPercentageChange = (dataset.GetValue(sample, targetVariable) - prevOriginal) / prevOriginal; 56 56 estimatedPercentageChange = (evaluator.Evaluate(sample) - prevOriginal) / prevOriginal; 57 if (updateTargetValues) { 58 dataset.SetValue(sample, targetVariable, estimatedPercentageChange * prevOriginal + prevOriginal); 59 } 57 60 58 } else { 61 59 originalPercentageChange = dataset.GetValue(sample, targetVariable); 62 60 estimatedPercentageChange = evaluator.Evaluate(sample); 63 if (updateTargetValues) { 64 dataset.SetValue(sample, targetVariable, estimatedPercentageChange); 65 } 61 66 62 } 67 63 if (!double.IsNaN(originalPercentageChange) && !double.IsInfinity(originalPercentageChange)) { -
trunk/sources/HeuristicLab.GP.StructureIdentification.TimeSeries/3.3/OffspringSelectionGPTimeSeriesPrognosis.cs
r2566 r2577 45 45 } 46 46 47 public bool UseEstimatedTargetValue {48 get { return GetVariableInjector().GetVariable("UseEstimatedTargetValue").GetValue<BoolData>().Data; }49 set { GetVariableInjector().GetVariable("UseEstimatedTargetValue").GetValue<BoolData>().Data = value; }50 }51 52 47 protected override IOperator CreateProblemInjector() { 53 48 return DefaultTimeSeriesOperators.CreateProblemInjector(); … … 71 66 injector.AddVariable(new HeuristicLab.Core.Variable("MinTimeOffset", new IntData())); 72 67 injector.AddVariable(new HeuristicLab.Core.Variable("MaxTimeOffset", new IntData())); 73 injector.AddVariable(new HeuristicLab.Core.Variable("UseEstimatedTargetValue", new BoolData()));74 68 return injector; 75 69 } -
trunk/sources/HeuristicLab.GP.StructureIdentification.TimeSeries/3.3/ProfitEvaluator.cs
r2222 r2577 38 38 } 39 39 40 public override void Evaluate(IScope scope, ITreeEvaluator evaluator, HeuristicLab.DataAnalysis.Dataset dataset, int targetVariable, int start, int end , bool updateTargetValues) {40 public override void Evaluate(IScope scope, ITreeEvaluator evaluator, HeuristicLab.DataAnalysis.Dataset dataset, int targetVariable, int start, int end) { 41 41 int exchangeRateVarIndex = GetVariableValue<IntData>("ExchangeRate", scope, true).Data; 42 42 double transactionCost = GetVariableValue<DoubleData>("TransactionCost", scope, true).Data; … … 54 54 double originalPercentageChange = dataset.GetValue(sample, targetVariable); 55 55 double estimatedPercentageChange = evaluator.Evaluate(sample); 56 if (updateTargetValues) { 57 dataset.SetValue(sample, targetVariable, estimatedPercentageChange); 58 } 56 59 57 if (!double.IsNaN(originalPercentageChange) && !double.IsInfinity(originalPercentageChange)) { 60 58 if (estimatedPercentageChange > 0) { -
trunk/sources/HeuristicLab.GP.StructureIdentification.TimeSeries/3.3/StandardGPTimeSeriesPrognosis.cs
r2566 r2577 45 45 } 46 46 47 public bool UseEstimatedTargetValue {48 get { return GetVariableInjector().GetVariable("UseEstimatedTargetValue").GetValue<BoolData>().Data; }49 set { GetVariableInjector().GetVariable("UseEstimatedTargetValue").GetValue<BoolData>().Data = value; }50 }51 52 47 protected override IOperator CreateProblemInjector() { 53 48 return DefaultTimeSeriesOperators.CreateProblemInjector(); … … 75 70 injector.AddVariable(new HeuristicLab.Core.Variable("MinTimeOffset", new IntData())); 76 71 injector.AddVariable(new HeuristicLab.Core.Variable("MaxTimeOffset", new IntData())); 77 injector.AddVariable(new HeuristicLab.Core.Variable("UseEstimatedTargetValue", new BoolData()));78 72 return injector; 79 73 } -
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.