Changeset 7100 for branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis/3.4/SingleObjective
- Timestamp:
- 11/29/11 20:05:38 (13 years ago)
- Location:
- branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis/3.4
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis/3.4
- Property svn:ignore
-
old new 3 3 HeuristicLabProblemsDataAnalysisSymbolicTimeSeriesPrognosisPlugin.cs 4 4 obj 5 Plugin.cs
-
- Property svn:ignore
-
branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis/3.4/SingleObjective/SymbolicTimeSeriesPrognosisSingleObjectiveMeanSquaredErrorEvaluator.cs
r6802 r7100 48 48 IEnumerable<int> rows = GenerateRowsToEvaluate(); 49 49 50 double quality = Calculate(Symbolic DataAnalysisTreeInterpreterParameter.ActualValue, solution, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, ProblemDataParameter.ActualValue, rows);50 double quality = Calculate(SymbolicTimeSeriesPrognosisInterpreterParameter.ActualValue, solution, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, ProblemDataParameter.ActualValue, rows); 51 51 QualityParameter.ActualValue = new DoubleValue(quality); 52 52 … … 56 56 public static double Calculate(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, ISymbolicExpressionTree solution, double lowerEstimationLimit, double upperEstimationLimit, ITimeSeriesPrognosisProblemData problemData, IEnumerable<int> rows) { 57 57 IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows); 58 IEnumerable<double> originalValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows); 59 IEnumerable<double> boundedEstimationValues = estimatedValues.LimitToRange(lowerEstimationLimit, upperEstimationLimit); 60 OnlineCalculatorError errorState; 61 double mse = OnlineMeanSquaredErrorCalculator.Calculate(originalValues, boundedEstimationValues, out errorState); 62 if (errorState != OnlineCalculatorError.None) return double.NaN; 63 else return mse; 58 OnlineMeanAndVarianceCalculator meanCalculator = new OnlineMeanAndVarianceCalculator(); 59 foreach (var targetVariable in problemData.TargetVariables) { 60 IEnumerable<double> originalValues = problemData.Dataset.GetDoubleValues(targetVariable, rows); 61 IEnumerable<double> boundedEstimationValues = estimatedValues.LimitToRange(lowerEstimationLimit, 62 upperEstimationLimit); 63 OnlineCalculatorError errorState; 64 meanCalculator.Add(OnlineMeanSquaredErrorCalculator.Calculate(originalValues, boundedEstimationValues, out errorState)); 65 if (errorState != OnlineCalculatorError.None) return double.NaN; 66 } 67 return meanCalculator.Mean; 64 68 } 65 69 66 70 public override double Evaluate(IExecutionContext context, ISymbolicExpressionTree tree, ITimeSeriesPrognosisProblemData problemData, IEnumerable<int> rows) { 67 Symbolic DataAnalysisTreeInterpreterParameter.ExecutionContext = context;71 SymbolicTimeSeriesPrognosisInterpreterParameter.ExecutionContext = context; 68 72 EstimationLimitsParameter.ExecutionContext = context; 69 73 70 double mse = Calculate(Symbolic DataAnalysisTreeInterpreterParameter.ActualValue, tree, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, problemData, rows);74 double mse = Calculate(SymbolicTimeSeriesPrognosisInterpreterParameter.ActualValue, tree, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, problemData, rows); 71 75 72 76 73 Symbolic DataAnalysisTreeInterpreterParameter.ExecutionContext = null;77 SymbolicTimeSeriesPrognosisInterpreterParameter.ExecutionContext = null; 74 78 EstimationLimitsParameter.ExecutionContext = null; 75 79 -
branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis/3.4/SingleObjective/SymbolicTimeSeriesPrognosisSingleObjectivePearsonRSquaredEvaluator.cs
r6802 r7100 48 48 IEnumerable<int> rows = GenerateRowsToEvaluate(); 49 49 50 double quality = Calculate(Symbolic DataAnalysisTreeInterpreterParameter.ActualValue, solution, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, ProblemDataParameter.ActualValue, rows);50 double quality = Calculate(SymbolicTimeSeriesPrognosisInterpreterParameter.ActualValue, solution, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, ProblemDataParameter.ActualValue, rows); 51 51 QualityParameter.ActualValue = new DoubleValue(quality); 52 52 … … 56 56 public static double Calculate(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, ISymbolicExpressionTree solution, double lowerEstimationLimit, double upperEstimationLimit, ITimeSeriesPrognosisProblemData problemData, IEnumerable<int> rows) { 57 57 IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows); 58 IEnumerable<double> originalValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows); 59 OnlineCalculatorError errorState; 60 double r2 = OnlinePearsonsRSquaredCalculator.Calculate(estimatedValues, originalValues, out errorState); 61 if (errorState != OnlineCalculatorError.None) return 0.0; 62 else return r2; 58 var meanCalculator = new OnlineMeanAndVarianceCalculator(); 59 foreach (var targetVariable in problemData.TargetVariables) { 60 IEnumerable<double> originalValues = problemData.Dataset.GetDoubleValues(targetVariable, rows); 61 OnlineCalculatorError errorState; 62 meanCalculator.Add(OnlinePearsonsRSquaredCalculator.Calculate(estimatedValues, originalValues, out errorState)); 63 if (errorState != OnlineCalculatorError.None) return 0.0; 64 } 65 return meanCalculator.Mean; 63 66 } 64 67 65 68 public override double Evaluate(IExecutionContext context, ISymbolicExpressionTree tree, ITimeSeriesPrognosisProblemData problemData, IEnumerable<int> rows) { 66 Symbolic DataAnalysisTreeInterpreterParameter.ExecutionContext = context;69 SymbolicTimeSeriesPrognosisInterpreterParameter.ExecutionContext = context; 67 70 EstimationLimitsParameter.ExecutionContext = context; 68 71 69 double r2 = Calculate(Symbolic DataAnalysisTreeInterpreterParameter.ActualValue, tree, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, problemData, rows);72 double r2 = Calculate(SymbolicTimeSeriesPrognosisInterpreterParameter.ActualValue, tree, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, problemData, rows); 70 73 71 Symbolic DataAnalysisTreeInterpreterParameter.ExecutionContext = null;74 SymbolicTimeSeriesPrognosisInterpreterParameter.ExecutionContext = null; 72 75 EstimationLimitsParameter.ExecutionContext = null; 73 76 -
branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis/3.4/SingleObjective/SymbolicTimeSeriesPrognosisSingleObjectiveProblem.cs
r7099 r7100 69 69 UpdateEstimationLimits(); 70 70 } 71 71 72 72 private void ConfigureGrammarSymbols() { 73 73 var grammar = SymbolicExpressionTreeGrammar as TypeCoherentExpressionGrammar; … … 77 77 private void InitializeOperators() { 78 78 Operators.Add(new SymbolicTimeSeriesPrognosisSingleObjectiveTrainingBestSolutionAnalyzer()); 79 Operators.Add(new SymbolicTimeSeriesPrognosisSingleObjectiveValidationBestSolutionAnalyzer());80 Operators.Add(new SymbolicTimeSeriesPrognosisSingleObjectiveOverfittingAnalyzer());79 //Operators.Add(new SymbolicTimeSeriesPrognosisSingleObjectiveValidationBestSolutionAnalyzer()); 80 //Operators.Add(new SymbolicTimeSeriesPrognosisSingleObjectiveOverfittingAnalyzer()); 81 81 ParameterizeOperators(); 82 82 } 83 83 84 84 private void UpdateEstimationLimits() { 85 if (ProblemData.TrainingIndizes.Any()) {86 var targetValues = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TrainingIndizes).ToList();87 var mean = targetValues.Average();88 var range = targetValues.Max() - targetValues.Min();89 EstimationLimits.Upper = mean + PunishmentFactor * range;90 EstimationLimits.Lower = mean - PunishmentFactor * range;91 } else {92 93 94 }85 //if (ProblemData.TrainingIndizes.Any()) { 86 // var targetValues = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariables, ProblemData.TrainingIndizes).ToList(); 87 // var mean = targetValues.Average(); 88 // var range = targetValues.Max() - targetValues.Min(); 89 // EstimationLimits.Upper = mean + PunishmentFactor * range; 90 // EstimationLimits.Lower = mean - PunishmentFactor * range; 91 //} else { 92 EstimationLimits.Upper = double.MaxValue; 93 EstimationLimits.Lower = double.MinValue; 94 //} 95 95 } 96 96 -
branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis/3.4/SingleObjective/SymbolicTimeSeriesPrognosisSingleObjectiveTrainingBestSolutionAnalyzer.cs
r6802 r7100 34 34 [StorableClass] 35 35 public sealed class SymbolicTimeSeriesPrognosisSingleObjectiveTrainingBestSolutionAnalyzer : SymbolicDataAnalysisSingleObjectiveTrainingBestSolutionAnalyzer<ISymbolicTimeSeriesPrognosisSolution>, 36 ISymbolic DataAnalysisInterpreterOperator, ISymbolicDataAnalysisBoundedOperator {36 ISymbolicTimeSeriesPrognosisInterpreterOperator, ISymbolicDataAnalysisBoundedOperator { 37 37 private const string ProblemDataParameterName = "ProblemData"; 38 private const string Symbolic DataAnalysisTreeInterpreterParameterName = "SymbolicDataAnalysisTreeInterpreter";38 private const string SymbolicTimeSeriesPrognosisInterpreterParameterName = "SymbolicTimeSeriesPrognosisInterpreter"; 39 39 private const string EstimationLimitsParameterName = "EstimationLimits"; 40 40 private const string ApplyLinearScalingParameterName = "ApplyLinearScaling"; … … 43 43 get { return (ILookupParameter<ITimeSeriesPrognosisProblemData>)Parameters[ProblemDataParameterName]; } 44 44 } 45 public ILookupParameter<ISymbolic DataAnalysisExpressionTreeInterpreter> SymbolicDataAnalysisTreeInterpreterParameter {46 get { return (ILookupParameter<ISymbolic DataAnalysisExpressionTreeInterpreter>)Parameters[SymbolicDataAnalysisTreeInterpreterParameterName]; }45 public ILookupParameter<ISymbolicTimeSeriesPrognosisInterpreter> SymbolicTimeSeriesPrognosisInterpreterParameter { 46 get { return (ILookupParameter<ISymbolicTimeSeriesPrognosisInterpreter>)Parameters[SymbolicTimeSeriesPrognosisInterpreterParameterName]; } 47 47 } 48 48 public IValueLookupParameter<DoubleLimit> EstimationLimitsParameter { … … 66 66 : base() { 67 67 Parameters.Add(new LookupParameter<ITimeSeriesPrognosisProblemData>(ProblemDataParameterName, "The problem data for the symbolic regression solution.")); 68 Parameters.Add(new LookupParameter<ISymbolic DataAnalysisExpressionTreeInterpreter>(SymbolicDataAnalysisTreeInterpreterParameterName, "The symbolic data analysis treeinterpreter for the symbolic expression tree."));68 Parameters.Add(new LookupParameter<ISymbolicTimeSeriesPrognosisInterpreter>(SymbolicTimeSeriesPrognosisInterpreterParameterName, "The symbolic time series prognosis interpreter for the symbolic expression tree.")); 69 69 Parameters.Add(new ValueLookupParameter<DoubleLimit>(EstimationLimitsParameterName, "The lower and upper limit for the estimated values produced by the symbolic regression model.")); 70 70 Parameters.Add(new ValueParameter<BoolValue>(ApplyLinearScalingParameterName, "Flag that indicates if the produced symbolic regression solution should be linearly scaled.", new BoolValue(true))); … … 75 75 76 76 protected override ISymbolicTimeSeriesPrognosisSolution CreateSolution(ISymbolicExpressionTree bestTree, double bestQuality) { 77 var model = new SymbolicTimeSeriesPrognosisModel((ISymbolicExpressionTree)bestTree.Clone(), Symbolic DataAnalysisTreeInterpreterParameter.ActualValue, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper);77 var model = new SymbolicTimeSeriesPrognosisModel((ISymbolicExpressionTree)bestTree.Clone(), SymbolicTimeSeriesPrognosisInterpreterParameter.ActualValue); 78 78 if (ApplyLinearScaling.Value) 79 79 SymbolicTimeSeriesPrognosisModel.Scale(model, ProblemDataParameter.ActualValue); -
branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis/3.4/SingleObjective/SymbolicTimeSeriesPrognosisSingleObjectiveValidationBestSolutionAnalyzer.cs
r6802 r7100 67 67 68 68 protected override ISymbolicTimeSeriesPrognosisSolution CreateSolution(ISymbolicExpressionTree bestTree, double bestQuality) { 69 var model = new SymbolicTimeSeriesPrognosisModel((ISymbolicExpressionTree)bestTree.Clone(), Symbolic DataAnalysisTreeInterpreterParameter.ActualValue, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper);69 var model = new SymbolicTimeSeriesPrognosisModel((ISymbolicExpressionTree)bestTree.Clone(), SymbolicTimeSeriesPrognosisInterpreterParameter.ActualValue); 70 70 if (ApplyLinearScaling.Value) 71 71 SymbolicTimeSeriesPrognosisModel.Scale(model, ProblemDataParameter.ActualValue);
Note: See TracChangeset
for help on using the changeset viewer.