Changeset 4366 for branches/HeuristicLab.Classification/HeuristicLab.Problems.DataAnalysis.Classification/3.3/Symbolic
- Timestamp:
- 09/07/10 10:03:21 (14 years ago)
- Location:
- branches/HeuristicLab.Classification/HeuristicLab.Problems.DataAnalysis.Classification/3.3
- Files:
-
- 3 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Classification/HeuristicLab.Problems.DataAnalysis.Classification/3.3
- Property svn:ignore
-
old new 3 3 obj 4 4 HeuristicLabProblemsDataAnalysisClassifcationPlugin.cs 5 HeuristicLabProblemsDataAnalysisClassificationPlugin.cs
-
- Property svn:ignore
-
branches/HeuristicLab.Classification/HeuristicLab.Problems.DataAnalysis.Classification/3.3/Symbolic/SingleObjectiveSymbolicClassificationEvaluator.cs
r4323 r4366 61 61 } 62 62 63 public ILookupParameter< DataAnalysisProblemData> RegressionProblemDataParameter {64 get { return (ILookupParameter< DataAnalysisProblemData>)Parameters[RegressionProblemDataParameterName]; }63 public ILookupParameter<ClassificationProblemData> RegressionProblemDataParameter { 64 get { return (ILookupParameter<ClassificationProblemData>)Parameters[RegressionProblemDataParameterName]; } 65 65 } 66 66 … … 92 92 get { return SymbolicExpressionTreeParameter.ActualValue; } 93 93 } 94 public DataAnalysisProblemData RegressionProblemData {94 public ClassificationProblemData RegressionProblemData { 95 95 get { return RegressionProblemDataParameter.ActualValue; } 96 96 } … … 118 118 Parameters.Add(new LookupParameter<ISymbolicExpressionTreeInterpreter>(SymbolicExpressionTreeInterpreterParameterName, "The interpreter that should be used to calculate the output values of the symbolic expression tree.")); 119 119 Parameters.Add(new LookupParameter<SymbolicExpressionTree>(FunctionTreeParameterName, "The symbolic regression solution encoded as a symbolic expression tree.")); 120 Parameters.Add(new LookupParameter< DataAnalysisProblemData>(RegressionProblemDataParameterName, "The problem data on which the symbolic regression solution should be evaluated."));120 Parameters.Add(new LookupParameter<ClassificationProblemData>(RegressionProblemDataParameterName, "The problem data on which the symbolic regression solution should be evaluated.")); 121 121 Parameters.Add(new ValueLookupParameter<IntValue>(SamplesStartParameterName, "The start index of the dataset partition on which the symbolic regression solution should be evaluated.")); 122 122 Parameters.Add(new ValueLookupParameter<IntValue>(SamplesEndParameterName, "The end index of the dataset partition on which the symbolic regression solution should be evaluated.")); … … 139 139 int seed = Random.Next(); 140 140 IEnumerable<int> rows = GenerateRowsToEvaluate(seed, RelativeNumberOfEvaluatedSamples.Value, SamplesStart.Value, SamplesEnd.Value); 141 141 142 double quality = Evaluate(SymbolicExpressionTreeInterpreter, SymbolicExpressionTree, LowerEstimationLimit.Value, UpperEstimationLimit.Value, 142 RegressionProblemData.Dataset, 143 RegressionProblemData.TargetVariable.Value, rows); 143 RegressionProblemData.Dataset, RegressionProblemData.TargetVariable.Value, RegressionProblemData.SortedClassValues, rows); 144 144 QualityParameter.ActualValue = new DoubleValue(quality); 145 145 return base.Apply(); … … 157 157 Dataset dataset, 158 158 string targetVariable, 159 IEnumerable<double> sortedClassValues, 159 160 IEnumerable<int> rows); 160 161 } -
branches/HeuristicLab.Classification/HeuristicLab.Problems.DataAnalysis.Classification/3.3/Symbolic/SymbolicClassificationMeanSquaredErrorEvaluator.cs
r4323 r4366 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Linq; 25 using HeuristicLab.Common; 24 26 using HeuristicLab.Core; 25 27 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; … … 37 39 } 38 40 39 public override double Evaluate(ISymbolicExpressionTreeInterpreter interpreter, SymbolicExpressionTree solution, double lowerEstimationLimit, double upperEstimationLimit, Dataset dataset, string targetVariable, IEnumerable< int> rows) {40 double mse = Calculate(interpreter, solution, lowerEstimationLimit, upperEstimationLimit, dataset, targetVariable, rows);41 public override double Evaluate(ISymbolicExpressionTreeInterpreter interpreter, SymbolicExpressionTree solution, double lowerEstimationLimit, double upperEstimationLimit, Dataset dataset, string targetVariable, IEnumerable<double> sortedClassValues, IEnumerable<int> rows) { 42 double mse = Calculate(interpreter, solution, lowerEstimationLimit, upperEstimationLimit, dataset, targetVariable, sortedClassValues, rows); 41 43 return mse; 42 44 } 43 45 44 public static double Calculate(ISymbolicExpressionTreeInterpreter interpreter, SymbolicExpressionTree solution, double lowerEstimationLimit, double upperEstimationLimit, Dataset dataset, string targetVariable, IEnumerable< int> rows) {46 public static double Calculate(ISymbolicExpressionTreeInterpreter interpreter, SymbolicExpressionTree solution, double lowerEstimationLimit, double upperEstimationLimit, Dataset dataset, string targetVariable, IEnumerable<double> sortedClassValues, IEnumerable<int> rows) { 45 47 IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, dataset, rows); 46 48 IEnumerable<double> originalValues = dataset.GetEnumeratedVariableValues(targetVariable, rows); … … 49 51 OnlineMeanSquaredErrorEvaluator mseEvaluator = new OnlineMeanSquaredErrorEvaluator(); 50 52 53 54 double firstClassValue = sortedClassValues.First(); 55 double lastClassValue = sortedClassValues.Last(); 51 56 while (originalEnumerator.MoveNext() && estimatedEnumerator.MoveNext()) { 52 57 double estimated = estimatedEnumerator.Current; … … 54 59 if (double.IsNaN(estimated)) 55 60 estimated = upperEstimationLimit; 61 else if (estimated < original && original.IsAlmost(firstClassValue)) 62 estimated = original; 63 else if (estimated > original && original.IsAlmost(lastClassValue)) 64 estimated = original; 56 65 else 57 66 estimated = Math.Min(upperEstimationLimit, Math.Max(lowerEstimationLimit, estimated)); -
branches/HeuristicLab.Classification/HeuristicLab.Problems.DataAnalysis.Classification/3.3/Symbolic/SymbolicClassificationProblem.cs
r4323 r4366 21 21 22 22 using System; 23 using System.Collections.Generic; 23 24 using System.Linq; 24 25 using HeuristicLab.Core; … … 28 29 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Creators; 29 30 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Interfaces; 31 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols; 30 32 using HeuristicLab.Parameters; 31 33 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 32 34 using HeuristicLab.PluginInfrastructure; 33 35 using HeuristicLab.Problems.DataAnalysis.Symbolic; 36 using HeuristicLab.Problems.DataAnalysis.Symbolic.Symbols; 34 37 35 38 namespace HeuristicLab.Problems.DataAnalysis.Classification { … … 52 55 protected set { SymbolicExpressionTreeInterpreterParameter.Value = value; } 53 56 } 54 public ValueParameter<ISymbolicExpressionTreeInterpreter> SymbolicExpressionTreeInterpreterParameter {55 get { return ( ValueParameter<ISymbolicExpressionTreeInterpreter>)Parameters[SymbolicExpressionTreeInterpreterParameterName]; }57 public IValueParameter<ISymbolicExpressionTreeInterpreter> SymbolicExpressionTreeInterpreterParameter { 58 get { return (IValueParameter<ISymbolicExpressionTreeInterpreter>)Parameters[SymbolicExpressionTreeInterpreterParameterName]; } 56 59 } 57 60 … … 60 63 protected set { FunctionTreeGrammarParameter.Value = value; } 61 64 } 62 public ValueParameter<ISymbolicExpressionGrammar> FunctionTreeGrammarParameter {63 get { return ( ValueParameter<ISymbolicExpressionGrammar>)Parameters[FunctionTreeGrammarParameterName]; }65 public IValueParameter<ISymbolicExpressionGrammar> FunctionTreeGrammarParameter { 66 get { return (IValueParameter<ISymbolicExpressionGrammar>)Parameters[FunctionTreeGrammarParameterName]; } 64 67 } 65 68 … … 68 71 protected set { MaxExpressionLengthParameter.Value = value; } 69 72 } 70 public ValueParameter<IntValue> MaxExpressionLengthParameter {71 get { return ( ValueParameter<IntValue>)Parameters[MaxExpressionLengthParameterName]; }73 public IValueParameter<IntValue> MaxExpressionLengthParameter { 74 get { return (IValueParameter<IntValue>)Parameters[MaxExpressionLengthParameterName]; } 72 75 } 73 76 … … 84 87 protected set { UpperEstimationLimitParameter.Value = value; } 85 88 } 86 public ValueParameter<DoubleValue> UpperEstimationLimitParameter {87 get { return ( ValueParameter<DoubleValue>)Parameters[UpperEstimationLimitParameterName]; }89 public IValueParameter<DoubleValue> UpperEstimationLimitParameter { 90 get { return (IValueParameter<DoubleValue>)Parameters[UpperEstimationLimitParameterName]; } 88 91 } 89 92 … … 92 95 protected set { LowerEstimationLimitParameter.Value = value; } 93 96 } 94 public ValueParameter<DoubleValue> LowerEstimationLimitParameter {95 get { return ( ValueParameter<DoubleValue>)Parameters[LowerEstimationLimitParameterName]; }97 public IValueParameter<DoubleValue> LowerEstimationLimitParameter { 98 get { return (IValueParameter<DoubleValue>)Parameters[LowerEstimationLimitParameterName]; } 96 99 } 97 100 … … 100 103 protected set { MaxFunctionDefiningBranchesParameter.Value = value; } 101 104 } 102 public ValueParameter<IntValue> MaxFunctionDefiningBranchesParameter {103 get { return ( ValueParameter<IntValue>)Parameters[MaxFunctionDefiningBranchensParameterName]; }105 public IValueParameter<IntValue> MaxFunctionDefiningBranchesParameter { 106 get { return (IValueParameter<IntValue>)Parameters[MaxFunctionDefiningBranchensParameterName]; } 104 107 } 105 108 … … 108 111 protected set { MaxFunctionArgumentsParameter.Value = value; } 109 112 } 110 public ValueParameter<IntValue> MaxFunctionArgumentsParameter {111 get { return ( ValueParameter<IntValue>)Parameters[MaxFunctionArgumentsParameterName]; }113 public IValueParameter<IntValue> MaxFunctionArgumentsParameter { 114 get { return (IValueParameter<IntValue>)Parameters[MaxFunctionArgumentsParameterName]; } 112 115 } 113 116 … … 225 228 Operators.AddRange(ApplicationManager.Manager.GetInstances<ISymbolicExpressionTreeOperator>().OfType<IOperator>()); 226 229 Operators.Add(new MinAverageMaxSymbolicExpressionTreeSizeAnalyzer()); 230 Operators.Add(new ValidationBestSymbolicClassificationSolutionAnalyzer()); 227 231 } 228 232 … … 249 253 250 254 private void ParameterizeGrammar() { 255 List<LaggedVariable> laggedSymbols = FunctionTreeGrammar.Symbols.OfType<LaggedVariable>().ToList(); 256 foreach (Symbol symbol in laggedSymbols) 257 FunctionTreeGrammar.RemoveSymbol(symbol); 251 258 foreach (var varSymbol in FunctionTreeGrammar.Symbols.OfType<HeuristicLab.Problems.DataAnalysis.Symbolic.Symbols.Variable>()) { 252 259 varSymbol.VariableNames = ClassificationProblemData.InputVariables.CheckedItems.Select(x => x.Value.Value); … … 287 294 288 295 private void ParameterizeAnalyzers() { 289 296 foreach (ISymbolicExpressionTreeAnalyzer analyzer in Operators.OfType<ISymbolicExpressionTreeAnalyzer>()) { 297 analyzer.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName; 298 var bestValidationSolutionAnalyzer = analyzer as ValidationBestSymbolicClassificationSolutionAnalyzer; 299 if (bestValidationSolutionAnalyzer != null) { 300 bestValidationSolutionAnalyzer.ClassificationProblemDataParameter.ActualName = ClassificationProblemDataParameter.Name; 301 bestValidationSolutionAnalyzer.UpperEstimationLimitParameter.ActualName = UpperEstimationLimitParameter.Name; 302 bestValidationSolutionAnalyzer.LowerEstimationLimitParameter.ActualName = LowerEstimationLimitParameter.Name; 303 bestValidationSolutionAnalyzer.SymbolicExpressionTreeInterpreterParameter.ActualName = SymbolicExpressionTreeInterpreterParameter.Name; 304 bestValidationSolutionAnalyzer.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName; 305 bestValidationSolutionAnalyzer.ValidationSamplesStartParameter.Value = ValidationSamplesStart; 306 bestValidationSolutionAnalyzer.ValidationSamplesEndParameter.Value = ValidationSamplesEnd; 307 } 308 } 290 309 } 291 310 #endregion
Note: See TracChangeset
for help on using the changeset viewer.