Changeset 9126 for branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers
- Timestamp:
- 01/08/13 15:36:13 (12 years ago)
- Location:
- branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic
- Files:
-
- 1 deleted
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic
- Property svn:mergeinfo changed
-
branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4
- Property svn:ignore
-
old new 1 *.user 2 Plugin.cs 1 3 bin 2 *.user3 HeuristicLabProblemsDataAnalysisSymbolicPlugin.cs4 4 obj 5 *.vs10x6 Plugin.cs
-
- Property svn:ignore
-
branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisAlleleFrequencyAnalyzer.cs
r7305 r9126 70 70 71 71 protected override Allele[] CalculateAlleles(ISymbolicExpressionTree solution) { 72 return GetAllSubtreesOfDepth(solution, AlleleTreeDepth) 72 return CalculateAlleles(solution, AlleleTreeDepth); 73 } 74 75 public static Allele[] CalculateAlleles(ISymbolicExpressionTree solution, int alleleTreedepth) { 76 return GetAllSubtreesOfDepth(solution, alleleTreedepth) 73 77 .AsParallel() 74 .Select(t => GetAlleleFromSubtreeOfDepth(t, AlleleTreeDepth))78 .Select(t => GetAlleleFromSubtreeOfDepth(t, alleleTreedepth)) 75 79 .ToArray(); 76 80 } 77 81 78 private Allele GetAlleleFromSubtreeOfDepth(ISymbolicExpressionTreeNode tree, int d) {82 private static Allele GetAlleleFromSubtreeOfDepth(ISymbolicExpressionTreeNode tree, int d) { 79 83 string textualRepresentation = GetTextualRepresentationFromSubtreeOfDepth(tree, d); 80 84 return new Allele(textualRepresentation); 81 85 } 82 86 83 private st ring GetTextualRepresentationFromSubtreeOfDepth(ISymbolicExpressionTreeNode tree, int d) {87 private static string GetTextualRepresentationFromSubtreeOfDepth(ISymbolicExpressionTreeNode tree, int d) { 84 88 if (d == 0) return ""; 85 89 StringBuilder builder = new StringBuilder(); … … 100 104 } 101 105 102 private IEnumerable<ISymbolicExpressionTreeNode> GetAllSubtreesOfDepth(ISymbolicExpressionTree solution, int d) {106 private static IEnumerable<ISymbolicExpressionTreeNode> GetAllSubtreesOfDepth(ISymbolicExpressionTree solution, int d) { 103 107 return from node in solution.IterateNodesPostfix() 104 108 where node.GetDepth() >= d -
branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisMultiObjectiveAnalyzer.cs
r7259 r9126 20 20 #endregion 21 21 22 using System.Collections.Generic;23 using System.Linq;24 22 using HeuristicLab.Common; 25 23 using HeuristicLab.Core; 26 24 using HeuristicLab.Data; 27 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;28 using HeuristicLab.Operators;29 25 using HeuristicLab.Parameters; 30 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 31 using HeuristicLab.Optimization;32 27 33 28 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { … … 39 34 private const string QualitiesParameterName = "Qualities"; 40 35 private const string MaximizationParameterName = "Maximization"; 36 private const string ApplyLinearScalingParameterName = "ApplyLinearScaling"; 41 37 #region parameter properties 42 38 public IScopeTreeLookupParameter<DoubleArray> QualitiesParameter { … … 45 41 public ILookupParameter<BoolArray> MaximizationParameter { 46 42 get { return (ILookupParameter<BoolArray>)Parameters[MaximizationParameterName]; } 43 } 44 public ILookupParameter<BoolValue> ApplyLinearScalingParameter { 45 get { return (ILookupParameter<BoolValue>)Parameters[ApplyLinearScalingParameterName]; } 47 46 } 48 47 #endregion … … 64 63 Parameters.Add(new ScopeTreeLookupParameter<DoubleArray>(QualitiesParameterName, "The qualities of the trees that should be analyzed.")); 65 64 Parameters.Add(new LookupParameter<BoolArray>(MaximizationParameterName, "The directions of optimization for each dimension.")); 65 Parameters.Add(new LookupParameter<BoolValue>(ApplyLinearScalingParameterName, "Flag that indicates if the individual should be linearly scaled before evaluating.")); 66 } 67 68 [StorableHook(HookType.AfterDeserialization)] 69 private void AfterDeserialization() { 70 if (Parameters.ContainsKey(ApplyLinearScalingParameterName) && Parameters[ApplyLinearScalingParameterName] is LookupParameter<BoolValue>) 71 Parameters.Remove(ApplyLinearScalingParameterName); 72 if (!Parameters.ContainsKey(ApplyLinearScalingParameterName)) 73 Parameters.Add(new LookupParameter<BoolValue>(ApplyLinearScalingParameterName, "Flag that indicates if the individual should be linearly scaled before evaluating.")); 66 74 } 67 75 } -
branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisSingleObjectiveAnalyzer.cs
r7259 r9126 20 20 #endregion 21 21 22 using System.Collections.Generic;23 using System.Linq;24 22 using HeuristicLab.Common; 25 23 using HeuristicLab.Core; 26 24 using HeuristicLab.Data; 27 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;28 using HeuristicLab.Operators;29 25 using HeuristicLab.Parameters; 30 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 31 using HeuristicLab.Optimization;32 27 33 28 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { … … 39 34 private const string QualityParameterName = "Quality"; 40 35 private const string MaximizationParameterName = "Maximization"; 36 private const string ApplyLinearScalingParameterName = "ApplyLinearScaling"; 37 41 38 #region parameter properties 42 39 public IScopeTreeLookupParameter<DoubleValue> QualityParameter { … … 45 42 public ILookupParameter<BoolValue> MaximizationParameter { 46 43 get { return (ILookupParameter<BoolValue>)Parameters[MaximizationParameterName]; } 44 } 45 public ILookupParameter<BoolValue> ApplyLinearScalingParameter { 46 get { return (ILookupParameter<BoolValue>)Parameters[ApplyLinearScalingParameterName]; } 47 47 } 48 48 #endregion … … 64 64 Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>(QualityParameterName, "The qualities of the trees that should be analyzed.")); 65 65 Parameters.Add(new LookupParameter<BoolValue>(MaximizationParameterName, "The direction of optimization.")); 66 Parameters.Add(new LookupParameter<BoolValue>(ApplyLinearScalingParameterName, "Flag that indicates if the individual should be linearly scaled before evaluating.")); 67 } 68 69 [StorableHook(HookType.AfterDeserialization)] 70 private void AfterDeserialization() { 71 if (Parameters.ContainsKey(ApplyLinearScalingParameterName) && !(Parameters[ApplyLinearScalingParameterName] is LookupParameter<BoolValue>)) 72 Parameters.Remove(ApplyLinearScalingParameterName); 73 if (!Parameters.ContainsKey(ApplyLinearScalingParameterName)) 74 Parameters.Add(new LookupParameter<BoolValue>(ApplyLinearScalingParameterName, "Flag that indicates if the individual should be linearly scaled before evaluating.")); 66 75 } 67 76 } -
branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisSingleObjectiveTrainingBestSolutionAnalyzer.cs
r7259 r9126 85 85 86 86 var results = ResultCollection; 87 if ( TrainingBestSolutionQuality == null ||88 IsBetter(bestQuality, TrainingBestSolutionQuality.Value, Maximization.Value)) {87 if (bestTree != null && (TrainingBestSolutionQuality == null || 88 IsBetter(bestQuality, TrainingBestSolutionQuality.Value, Maximization.Value))) { 89 89 TrainingBestSolution = CreateSolution(bestTree, bestQuality); 90 90 TrainingBestSolutionQuality = new DoubleValue(bestQuality); -
branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisSingleObjectiveTrainingParetoBestSolutionAnalyzer.cs
r7734 r9126 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 23 24 using System.Linq; … … 26 27 using HeuristicLab.Data; 27 28 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 28 using HeuristicLab.Operators;29 29 using HeuristicLab.Optimization; 30 30 using HeuristicLab.Parameters; 31 31 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 32 using System;33 32 34 33 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { … … 38 37 [Item("SymbolicDataAnalysisSingleObjectiveTrainingParetoBestSolutionAnalyzer", "An operator that analyzes the Pareto-best symbolic data analysis solution for single objective symbolic data analysis problems.")] 39 38 [StorableClass] 40 public abstract class SymbolicDataAnalysisSingleObjectiveTrainingParetoBestSolutionAnalyzer<T> : SymbolicDataAnalysisSingleObjectiveAnalyzer 41 where T : class, ISymbolicDataAnalysisSolution { 39 public abstract class SymbolicDataAnalysisSingleObjectiveTrainingParetoBestSolutionAnalyzer<S, T> : SymbolicDataAnalysisSingleObjectiveAnalyzer, ISymbolicDataAnalysisInterpreterOperator, ISymbolicDataAnalysisBoundedOperator 40 where T : class, ISymbolicDataAnalysisSolution 41 where S : class, IDataAnalysisProblemData { 42 private const string ProblemDataParameterName = "ProblemData"; 42 43 private const string TrainingBestSolutionsParameterName = "Best training solutions"; 43 44 private const string TrainingBestSolutionQualitiesParameterName = "Best training solution qualities"; 44 45 private const string ComplexityParameterName = "Complexity"; 46 private const string SymbolicDataAnalysisTreeInterpreterParameterName = "SymbolicDataAnalysisTreeInterpreter"; 47 private const string EstimationLimitsParameterName = "EstimationLimits"; 45 48 46 49 public override bool EnabledByDefault { … … 58 61 get { return (IScopeTreeLookupParameter<DoubleValue>)Parameters[ComplexityParameterName]; } 59 62 } 63 public ILookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter> SymbolicDataAnalysisTreeInterpreterParameter { 64 get { return (ILookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>)Parameters[SymbolicDataAnalysisTreeInterpreterParameterName]; } 65 } 66 public ILookupParameter<S> ProblemDataParameter { 67 get { return (ILookupParameter<S>)Parameters[ProblemDataParameterName]; } 68 } 69 public IValueLookupParameter<DoubleLimit> EstimationLimitsParameter { 70 get { return (IValueLookupParameter<DoubleLimit>)Parameters[EstimationLimitsParameterName]; } 71 } 60 72 #endregion 61 73 #region properties … … 72 84 [StorableConstructor] 73 85 protected SymbolicDataAnalysisSingleObjectiveTrainingParetoBestSolutionAnalyzer(bool deserializing) : base(deserializing) { } 74 protected SymbolicDataAnalysisSingleObjectiveTrainingParetoBestSolutionAnalyzer(SymbolicDataAnalysisSingleObjectiveTrainingParetoBestSolutionAnalyzer< T> original, Cloner cloner) : base(original, cloner) { }86 protected SymbolicDataAnalysisSingleObjectiveTrainingParetoBestSolutionAnalyzer(SymbolicDataAnalysisSingleObjectiveTrainingParetoBestSolutionAnalyzer<S, T> original, Cloner cloner) : base(original, cloner) { } 75 87 public SymbolicDataAnalysisSingleObjectiveTrainingParetoBestSolutionAnalyzer() 76 88 : base() { 89 Parameters.Add(new LookupParameter<S>(ProblemDataParameterName, "The problem data for the symbolic data analysis solution.")); 77 90 Parameters.Add(new LookupParameter<ItemList<T>>(TrainingBestSolutionsParameterName, "The training best (Pareto-optimal) symbolic data analysis solutions.")); 78 91 Parameters.Add(new LookupParameter<ItemList<DoubleArray>>(TrainingBestSolutionQualitiesParameterName, "The qualities of the training best (Pareto-optimal) solutions.")); 79 92 Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>(ComplexityParameterName, "The complexity of each tree.")); 93 Parameters.Add(new LookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>(SymbolicDataAnalysisTreeInterpreterParameterName, "The symbolic data analysis tree interpreter for the symbolic expression tree.")); 94 Parameters.Add(new ValueLookupParameter<DoubleLimit>(EstimationLimitsParameterName, "The lower and upper limit for the estimated values produced by the symbolic classification model.")); 80 95 } 81 96 … … 100 115 101 116 List<double> complexities; 102 if (ComplexityParameter.ActualValue != null ) {117 if (ComplexityParameter.ActualValue != null && ComplexityParameter.ActualValue.Length == qualities.Count) { 103 118 complexities = ComplexityParameter.ActualValue.Select(x => x.Value).ToList(); 104 119 } else { -
branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisSingleObjectiveValidationAnalyzer.cs
r7721 r9126 76 76 : base(original, cloner) { 77 77 } 78 public SymbolicDataAnalysisSingleObjectiveValidationAnalyzer() 79 78 79 protected SymbolicDataAnalysisSingleObjectiveValidationAnalyzer(): base() { 80 80 Parameters.Add(new LookupParameter<IRandom>(RandomParameterName, "The random generator.")); 81 81 Parameters.Add(new LookupParameter<U>(ProblemDataParameterName, "The problem data of the symbolic data analysis problem.")); 82 82 Parameters.Add(new LookupParameter<T>(EvaluatorParameterName, "The operator to use for fitness evaluation on the validation partition.")); 83 83 Parameters.Add(new LookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>(SymbolicDataAnalysisTreeInterpreterParameterName, "The interpreter for symbolic data analysis expression trees.")); 84 Parameters.Add(new ValueLookupParameter<IntRange>(ValidationPartitionParameterName, "The svalidation partition."));84 Parameters.Add(new ValueLookupParameter<IntRange>(ValidationPartitionParameterName, "The validation partition.")); 85 85 Parameters.Add(new ValueLookupParameter<PercentValue>(RelativeNumberOfEvaluatedSamplesParameterName, "The relative number of samples of the dataset partition, which should be randomly chosen for evaluation between the start and end index.")); 86 86 Parameters.Add(new ValueLookupParameter<PercentValue>(PercentageOfBestSolutionsParameterName, -
branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisSingleObjectiveValidationParetoBestSolutionAnalyzer.cs
r7734 r9126 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 23 24 using System.Linq; … … 26 27 using HeuristicLab.Data; 27 28 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 28 using HeuristicLab.Operators;29 29 using HeuristicLab.Optimization; 30 30 using HeuristicLab.Parameters; 31 31 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 32 using System;33 32 34 33 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { … … 38 37 [Item("SymbolicDataAnalysisSingleObjectiveValidationParetoBestSolutionAnalyzer", "An operator that analyzes the Pareto-best symbolic data analysis solution for single objective symbolic data analysis problems.")] 39 38 [StorableClass] 40 public abstract class SymbolicDataAnalysisSingleObjectiveValidationParetoBestSolutionAnalyzer<S, T, U> : SymbolicDataAnalysisSingleObjectiveValidationAnalyzer<T, U> 39 public abstract class SymbolicDataAnalysisSingleObjectiveValidationParetoBestSolutionAnalyzer<S, T, U> : SymbolicDataAnalysisSingleObjectiveValidationAnalyzer<T, U>, ISymbolicDataAnalysisBoundedOperator 41 40 where S : class, ISymbolicDataAnalysisSolution 42 41 where T : class, ISymbolicDataAnalysisSingleObjectiveEvaluator<U> … … 45 44 private const string ValidationBestSolutionQualitiesParameterName = "Best validation solution qualities"; 46 45 private const string ComplexityParameterName = "Complexity"; 46 private const string EstimationLimitsParameterName = "EstimationLimits"; 47 47 48 48 public override bool EnabledByDefault { … … 60 60 get { return (IScopeTreeLookupParameter<DoubleValue>)Parameters[ComplexityParameterName]; } 61 61 } 62 public IValueLookupParameter<DoubleLimit> EstimationLimitsParameter { 63 get { return (IValueLookupParameter<DoubleLimit>)Parameters[EstimationLimitsParameterName]; } 64 } 65 62 66 #endregion 63 67 #region properties … … 80 84 Parameters.Add(new LookupParameter<ItemList<DoubleArray>>(ValidationBestSolutionQualitiesParameterName, "The qualities of the validation best (Pareto-optimal) solutions.")); 81 85 Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>(ComplexityParameterName, "The complexity of each tree.")); 86 Parameters.Add(new ValueLookupParameter<DoubleLimit>(EstimationLimitsParameterName, "The lower and upper limit for the estimated values produced by the symbolic classification model.")); 82 87 } 83 88 … … 137 142 138 143 List<double> complexities; 139 if (ComplexityParameter.ActualValue != null ) {144 if (ComplexityParameter.ActualValue != null && ComplexityParameter.ActualValue.Length == trainingQuality.Length) { 140 145 complexities = ComplexityParameter.ActualValue.Select(x => x.Value).ToList(); 141 146 } else { -
branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisVariableFrequencyAnalyzer.cs
r7259 r9126 109 109 // update variable impacts matrix 110 110 var orderedImpacts = (from row in datatable.Rows 111 select new { Name = row.Name, Impact = datatable.Rows[row.Name].Values.Average() })111 select new { Name = row.Name, Impact = Math.Round(datatable.Rows[row.Name].Values.Average(), 3) }) 112 112 .OrderByDescending(p => p.Impact) 113 113 .ToList();
Note: See TracChangeset
for help on using the changeset viewer.