Changeset 8331 for branches/ScatterSearch (trunk integration)/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression
- Timestamp:
- 07/26/12 09:51:13 (12 years ago)
- Location:
- branches/ScatterSearch (trunk integration)
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ScatterSearch (trunk integration)
- Property svn:ignore
-
old new 21 21 protoc.exe 22 22 _ReSharper.HeuristicLab 3.3 Tests 23 Google.ProtocolBuffers-2.4.1.473.dll
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/ScatterSearch (trunk integration)/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/SymbolicRegressionMultiObjectiveProblem.cs
r8086 r8331 53 53 [StorableConstructor] 54 54 protected SymbolicRegressionMultiObjectiveProblem(bool deserializing) : base(deserializing) { } 55 protected SymbolicRegressionMultiObjectiveProblem(SymbolicRegressionMultiObjectiveProblem original, Cloner cloner) : base(original, cloner) { } 55 protected SymbolicRegressionMultiObjectiveProblem(SymbolicRegressionMultiObjectiveProblem original, Cloner cloner) 56 : base(original, cloner) { 57 RegisterEventHandlers(); 58 } 56 59 public override IDeepCloneable Clone(Cloner cloner) { return new SymbolicRegressionMultiObjectiveProblem(this, cloner); } 57 60 … … 66 69 MaximumSymbolicExpressionTreeLength.Value = InitialMaximumTreeLength; 67 70 68 SymbolicExpressionTreeGrammarParameter.ValueChanged += (o, e) => ConfigureGrammarSymbols(); 69 71 RegisterEventHandlers(); 70 72 ConfigureGrammarSymbols(); 71 73 InitializeOperators(); 72 74 UpdateEstimationLimits(); 75 } 76 77 [StorableHook(HookType.AfterDeserialization)] 78 private void AfterDeserialization() { 79 RegisterEventHandlers(); 80 } 81 82 private void RegisterEventHandlers() { 83 SymbolicExpressionTreeGrammarParameter.ValueChanged += (o, e) => ConfigureGrammarSymbols(); 73 84 } 74 85 … … 85 96 86 97 private void UpdateEstimationLimits() { 87 if (ProblemData.TrainingIndi zes.Any()) {88 var targetValues = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TrainingIndi zes).ToList();98 if (ProblemData.TrainingIndices.Any()) { 99 var targetValues = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TrainingIndices).ToList(); 89 100 var mean = targetValues.Average(); 90 101 var range = targetValues.Max() - targetValues.Min(); -
branches/ScatterSearch (trunk integration)/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/Plugin.cs.frame
r7675 r8331 26 26 27 27 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression { 28 [Plugin("HeuristicLab.Problems.DataAnalysis.Symbolic.Regression","Provides classes to perform symbolic regression (single- or multiobjective).", "3.4. 2.$WCREV$")]28 [Plugin("HeuristicLab.Problems.DataAnalysis.Symbolic.Regression","Provides classes to perform symbolic regression (single- or multiobjective).", "3.4.3.$WCREV$")] 29 29 [PluginFile("HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4.dll", PluginFileType.Assembly)] 30 30 [PluginDependency("HeuristicLab.ALGLIB", "3.5")] -
branches/ScatterSearch (trunk integration)/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/Properties/AssemblyInfo.cs.frame
r7259 r8331 53 53 // by using the '*' as shown below: 54 54 [assembly: AssemblyVersion("3.4.0.0")] 55 [assembly: AssemblyFileVersion("3.4. 2.$WCREV$")]55 [assembly: AssemblyFileVersion("3.4.3.$WCREV$")] -
branches/ScatterSearch (trunk integration)/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectiveEvaluator.cs
r7677 r8331 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Linq; 24 25 using HeuristicLab.Common; 25 26 using HeuristicLab.Core; … … 59 60 private static double[] cache; 60 61 61 protected static void CalculateWithScaling(IEnumerable<double> targetValues, IEnumerable<double> estimatedValues, IOnlineCalculator calculator, int maxRows) { 62 protected static void CalculateWithScaling(IEnumerable<double> targetValues, IEnumerable<double> estimatedValues, 63 double lowerEstimationLimit, double upperEstimationLimit, 64 IOnlineCalculator calculator, int maxRows) { 62 65 if (cache == null || cache.GetLength(0) < maxRows) { 63 66 cache = new double[maxRows]; … … 83 86 //calculate the quality by using the passed online calculator 84 87 targetValuesEnumerator = targetValues.GetEnumerator(); 85 i = 0; 86 while (targetValuesEnumerator.MoveNext()) { 87 double target = targetValuesEnumerator.Current; 88 double estimated = cache[i] * beta + alpha; 89 calculator.Add(target, estimated); 90 i++; 88 var scaledBoundedEstimatedValuesEnumerator = Enumerable.Range(0, i).Select(x => cache[x] * beta + alpha) 89 .LimitToRange(lowerEstimationLimit, upperEstimationLimit).GetEnumerator(); 90 91 while (targetValuesEnumerator.MoveNext() & scaledBoundedEstimatedValuesEnumerator.MoveNext()) { 92 calculator.Add(targetValuesEnumerator.Current, scaledBoundedEstimatedValuesEnumerator.Current); 91 93 } 92 94 } -
branches/ScatterSearch (trunk integration)/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectiveMaxAbsoluteErrorEvaluator.cs
r7677 r8331 56 56 IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows); 57 57 IEnumerable<double> targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows); 58 IEnumerable<double> boundedEstimatedValues = estimatedValues.LimitToRange(lowerEstimationLimit, upperEstimationLimit);59 58 OnlineCalculatorError errorState; 60 59 … … 62 61 if (applyLinearScaling) { 63 62 var maeCalculator = new OnlineMaxAbsoluteErrorCalculator(); 64 CalculateWithScaling(targetValues, boundedEstimatedValues, maeCalculator, problemData.Dataset.Rows);63 CalculateWithScaling(targetValues, estimatedValues, lowerEstimationLimit, upperEstimationLimit, maeCalculator, problemData.Dataset.Rows); 65 64 errorState = maeCalculator.ErrorState; 66 65 mse = maeCalculator.MaxAbsoluteError; 67 } else 66 } else { 67 IEnumerable<double> boundedEstimatedValues = estimatedValues.LimitToRange(lowerEstimationLimit, upperEstimationLimit); 68 68 mse = OnlineMaxAbsoluteErrorCalculator.Calculate(targetValues, boundedEstimatedValues, out errorState); 69 69 } 70 70 if (errorState != OnlineCalculatorError.None) return Double.NaN; 71 71 else return mse; -
branches/ScatterSearch (trunk integration)/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectiveMeanAbsoluteErrorEvaluator.cs
r7677 r8331 56 56 IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows); 57 57 IEnumerable<double> targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows); 58 IEnumerable<double> boundedEstimatedValues = estimatedValues.LimitToRange(lowerEstimationLimit, upperEstimationLimit);59 58 OnlineCalculatorError errorState; 60 59 … … 62 61 if (applyLinearScaling) { 63 62 var maeCalculator = new OnlineMeanAbsoluteErrorCalculator(); 64 CalculateWithScaling(targetValues, boundedEstimatedValues, maeCalculator, problemData.Dataset.Rows);63 CalculateWithScaling(targetValues, estimatedValues, lowerEstimationLimit, upperEstimationLimit, maeCalculator, problemData.Dataset.Rows); 65 64 errorState = maeCalculator.ErrorState; 66 65 mse = maeCalculator.MeanAbsoluteError; 67 } else 66 } else { 67 IEnumerable<double> boundedEstimatedValues = estimatedValues.LimitToRange(lowerEstimationLimit, 68 upperEstimationLimit); 68 69 mse = OnlineMeanSquaredErrorCalculator.Calculate(targetValues, boundedEstimatedValues, out errorState); 69 70 } 70 71 if (errorState != OnlineCalculatorError.None) return Double.NaN; 71 72 else return mse; -
branches/ScatterSearch (trunk integration)/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectiveMeanSquaredErrorEvaluator.cs
r7677 r8331 56 56 IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows); 57 57 IEnumerable<double> targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows); 58 IEnumerable<double> boundedEstimatedValues = estimatedValues.LimitToRange(lowerEstimationLimit, upperEstimationLimit);59 58 OnlineCalculatorError errorState; 60 59 … … 62 61 if (applyLinearScaling) { 63 62 var mseCalculator = new OnlineMeanSquaredErrorCalculator(); 64 CalculateWithScaling(targetValues, boundedEstimatedValues, mseCalculator, problemData.Dataset.Rows);63 CalculateWithScaling(targetValues, estimatedValues, lowerEstimationLimit, upperEstimationLimit, mseCalculator, problemData.Dataset.Rows); 65 64 errorState = mseCalculator.ErrorState; 66 65 mse = mseCalculator.MeanSquaredError; 67 } else 66 } else { 67 IEnumerable<double> boundedEstimatedValues = estimatedValues.LimitToRange(lowerEstimationLimit, upperEstimationLimit); 68 68 mse = OnlineMeanSquaredErrorCalculator.Calculate(targetValues, boundedEstimatedValues, out errorState); 69 69 } 70 70 if (errorState != OnlineCalculatorError.None) return Double.NaN; 71 71 else return mse; -
branches/ScatterSearch (trunk integration)/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/SymbolicRegressionSingleObjectiveProblem.cs
r8086 r8331 49 49 [StorableConstructor] 50 50 protected SymbolicRegressionSingleObjectiveProblem(bool deserializing) : base(deserializing) { } 51 protected SymbolicRegressionSingleObjectiveProblem(SymbolicRegressionSingleObjectiveProblem original, Cloner cloner) : base(original, cloner) { } 51 protected SymbolicRegressionSingleObjectiveProblem(SymbolicRegressionSingleObjectiveProblem original, Cloner cloner) 52 : base(original, cloner) { 53 RegisterEventHandlers(); 54 } 52 55 public override IDeepCloneable Clone(Cloner cloner) { return new SymbolicRegressionSingleObjectiveProblem(this, cloner); } 53 56 … … 62 65 MaximumSymbolicExpressionTreeLength.Value = InitialMaximumTreeLength; 63 66 64 SymbolicExpressionTreeGrammarParameter.ValueChanged += (o, e) => ConfigureGrammarSymbols(); 65 67 RegisterEventHandlers(); 66 68 ConfigureGrammarSymbols(); 67 69 InitializeOperators(); 68 70 UpdateEstimationLimits(); 71 } 72 73 [StorableHook(HookType.AfterDeserialization)] 74 private void AfterDeserialization() { 75 RegisterEventHandlers(); 76 // compatibility 77 bool changed = false; 78 if (!Operators.OfType<SymbolicRegressionSingleObjectiveTrainingParetoBestSolutionAnalyzer>().Any()) { 79 Operators.Add(new SymbolicRegressionSingleObjectiveTrainingParetoBestSolutionAnalyzer()); 80 changed = true; 81 } 82 if (!Operators.OfType<SymbolicRegressionSingleObjectiveValidationParetoBestSolutionAnalyzer>().Any()) { 83 Operators.Add(new SymbolicRegressionSingleObjectiveValidationParetoBestSolutionAnalyzer()); 84 changed = true; 85 } 86 if (changed) { 87 ParameterizeOperators(); 88 } 89 } 90 91 private void RegisterEventHandlers() { 92 SymbolicExpressionTreeGrammarParameter.ValueChanged += (o, e) => ConfigureGrammarSymbols(); 69 93 } 70 94 … … 85 109 86 110 private void UpdateEstimationLimits() { 87 if (ProblemData.TrainingIndi zes.Any()) {88 var targetValues = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TrainingIndi zes).ToList();111 if (ProblemData.TrainingIndices.Any()) { 112 var targetValues = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TrainingIndices).ToList(); 89 113 var mean = targetValues.Average(); 90 114 var range = targetValues.Max() - targetValues.Min(); -
branches/ScatterSearch (trunk integration)/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/SymbolicRegressionSingleObjectiveTrainingParetoBestSolutionAnalyzer.cs
r7726 r8331 33 33 [Item("SymbolicRegressionSingleObjectiveTrainingParetoBestSolutionAnalyzer", "An operator that collects the training Pareto-best symbolic regression solutions for single objective symbolic regression problems.")] 34 34 [StorableClass] 35 public sealed class SymbolicRegressionSingleObjectiveTrainingParetoBestSolutionAnalyzer : SymbolicDataAnalysisSingleObjectiveTrainingParetoBestSolutionAnalyzer<ISymbolicRegressionSolution>, 36 ISymbolicDataAnalysisInterpreterOperator, ISymbolicDataAnalysisBoundedOperator { 37 private const string ProblemDataParameterName = "ProblemData"; 38 private const string SymbolicDataAnalysisTreeInterpreterParameterName = "SymbolicDataAnalysisTreeInterpreter"; 39 private const string EstimationLimitsParameterName = "EstimationLimits"; 35 public sealed class SymbolicRegressionSingleObjectiveTrainingParetoBestSolutionAnalyzer : SymbolicDataAnalysisSingleObjectiveTrainingParetoBestSolutionAnalyzer<IRegressionProblemData, ISymbolicRegressionSolution> { 40 36 private const string ApplyLinearScalingParameterName = "ApplyLinearScaling"; 41 37 #region parameter properties 42 public ILookupParameter<IRegressionProblemData> ProblemDataParameter {43 get { return (ILookupParameter<IRegressionProblemData>)Parameters[ProblemDataParameterName]; }44 }45 public ILookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter> SymbolicDataAnalysisTreeInterpreterParameter {46 get { return (ILookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>)Parameters[SymbolicDataAnalysisTreeInterpreterParameterName]; }47 }48 public IValueLookupParameter<DoubleLimit> EstimationLimitsParameter {49 get { return (IValueLookupParameter<DoubleLimit>)Parameters[EstimationLimitsParameterName]; }50 }51 38 public IValueParameter<BoolValue> ApplyLinearScalingParameter { 52 39 get { return (IValueParameter<BoolValue>)Parameters[ApplyLinearScalingParameterName]; } … … 65 52 public SymbolicRegressionSingleObjectiveTrainingParetoBestSolutionAnalyzer() 66 53 : base() { 67 Parameters.Add(new LookupParameter<IRegressionProblemData>(ProblemDataParameterName, "The problem data for the symbolic regression solution."));68 Parameters.Add(new LookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>(SymbolicDataAnalysisTreeInterpreterParameterName, "The symbolic data analysis tree interpreter for the symbolic expression tree."));69 Parameters.Add(new ValueLookupParameter<DoubleLimit>(EstimationLimitsParameterName, "The lower and upper limit for the estimated values produced by the symbolic regression model."));70 54 Parameters.Add(new ValueParameter<BoolValue>(ApplyLinearScalingParameterName, "Flag that indicates if the produced symbolic regression solution should be linearly scaled.", new BoolValue(true))); 71 55 } -
branches/ScatterSearch (trunk integration)/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/SymbolicRegressionSingleObjectiveValidationParetoBestSolutionAnalyzer.cs
r7734 r8331 33 33 [Item("SymbolicRegressionSingleObjectiveValidationParetoBestSolutionAnalyzer", "An operator that collects the validation Pareto-best symbolic regression solutions for single objective symbolic regression problems.")] 34 34 [StorableClass] 35 public sealed class SymbolicRegressionSingleObjectiveValidationParetoBestSolutionAnalyzer : SymbolicDataAnalysisSingleObjectiveValidationParetoBestSolutionAnalyzer<ISymbolicRegressionSolution, ISymbolicRegressionSingleObjectiveEvaluator, IRegressionProblemData>, 36 ISymbolicDataAnalysisInterpreterOperator, ISymbolicDataAnalysisBoundedOperator { 37 private const string EstimationLimitsParameterName = "EstimationLimits"; 35 public sealed class SymbolicRegressionSingleObjectiveValidationParetoBestSolutionAnalyzer : SymbolicDataAnalysisSingleObjectiveValidationParetoBestSolutionAnalyzer<ISymbolicRegressionSolution, ISymbolicRegressionSingleObjectiveEvaluator, IRegressionProblemData> { 38 36 private const string ApplyLinearScalingParameterName = "ApplyLinearScaling"; 39 37 #region parameter properties 40 public IValueLookupParameter<DoubleLimit> EstimationLimitsParameter {41 get { return (IValueLookupParameter<DoubleLimit>)Parameters[EstimationLimitsParameterName]; }42 }43 38 public IValueParameter<BoolValue> ApplyLinearScalingParameter { 44 39 get { return (IValueParameter<BoolValue>)Parameters[ApplyLinearScalingParameterName]; } … … 57 52 public SymbolicRegressionSingleObjectiveValidationParetoBestSolutionAnalyzer() 58 53 : base() { 59 Parameters.Add(new ValueLookupParameter<DoubleLimit>(EstimationLimitsParameterName, "The lower and upper limit for the estimated values produced by the symbolic regression model."));60 54 Parameters.Add(new ValueParameter<BoolValue>(ApplyLinearScalingParameterName, "Flag that indicates if the produced symbolic regression solution should be linearly scaled.", new BoolValue(true))); 61 55 } -
branches/ScatterSearch (trunk integration)/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionModel.cs
r8086 r8331 73 73 var dataset = problemData.Dataset; 74 74 var targetVariable = problemData.TargetVariable; 75 var rows = problemData.TrainingIndi zes;75 var rows = problemData.TrainingIndices; 76 76 var estimatedValues = model.Interpreter.GetSymbolicExpressionTreeValues(model.SymbolicExpressionTree, dataset, rows); 77 77 var targetValues = dataset.GetDoubleValues(targetVariable, rows);
Note: See TracChangeset
for help on using the changeset viewer.