- Timestamp:
- 10/19/08 00:51:39 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.GP.StructureIdentification.TimeSeries/TheilInequalityCoefficientEvaluator.cs
r686 r692 30 30 namespace HeuristicLab.GP.StructureIdentification.TimeSeries { 31 31 public class TheilInequalityCoefficientEvaluator : GPEvaluatorBase { 32 private bool differential;33 32 private DoubleData theilInequaliy; 34 33 public override string Description { … … 41 40 public TheilInequalityCoefficientEvaluator() 42 41 : base() { 43 AddVariableInfo(new VariableInfo("Differential", "Wether to calculate the coefficient for the predicted change vs. original change or for the absolute prediction vs. original value", typeof(BoolData), VariableKind.In));44 42 AddVariableInfo(new VariableInfo("TheilInequalityCoefficient", "Theil's inequality coefficient of the model", typeof(DoubleData), VariableKind.New)); 45 46 43 } 47 44 48 45 public override IOperation Apply(IScope scope) { 49 differential = GetVariableValue<BoolData>("Differential", scope, true).Data;50 46 theilInequaliy = GetVariableValue<DoubleData>("TheilInequalityCoefficient", scope, false, false); 51 47 if(theilInequaliy == null) { … … 53 49 scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("TheilInequalityCoefficient"), theilInequaliy)); 54 50 } 55 56 51 return base.Apply(scope); 57 52 } … … 59 54 public override void Evaluate(int start, int end) { 60 55 double errorsSquaredSum = 0.0; 61 double estimatedSquaredSum = 0.0;62 56 double originalSquaredSum = 0.0; 63 57 for(int sample = start; sample < end; sample++) { 64 double prevValue = 0.0; 65 if(differential) prevValue = GetOriginalValue(sample - 1); 58 double prevValue = GetOriginalValue(sample - 1); 66 59 double estimatedChange = GetEstimatedValue(sample) - prevValue; 67 60 double originalChange = GetOriginalValue(sample) - prevValue; … … 70 63 double error = estimatedChange - originalChange; 71 64 errorsSquaredSum += error * error; 72 estimatedSquaredSum += estimatedChange * estimatedChange;73 65 originalSquaredSum += originalChange * originalChange; 74 66 } 75 67 } 76 68 int nSamples = end - start; 77 double quality = Math.Sqrt(errorsSquaredSum / nSamples) / (Math.Sqrt(estimatedSquaredSum / nSamples) + Math.Sqrt(originalSquaredSum / nSamples));69 double quality = Math.Sqrt(errorsSquaredSum / nSamples) / Math.Sqrt(originalSquaredSum / nSamples); 78 70 if(double.IsNaN(quality) || double.IsInfinity(quality)) 79 71 quality = double.MaxValue;
Note: See TracChangeset
for help on using the changeset viewer.