Changeset 15860 for branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration
- Timestamp:
- 03/23/18 18:36:23 (7 years ago)
- Location:
- branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/Analysis/RSquaredEvaluator.cs
r15859 r15860 77 77 problemData.TrainingIndices, 78 78 applyLinearScaling: false, 79 maxIterations: 200,79 maxIterations: 50, 80 80 updateVariableWeights: true, 81 81 updateConstantsInTree: true); … … 96 96 //var estVals = model.GetEstimatedValues(problemData.Dataset, problemData.TrainingIndices); 97 97 //OnlineCalculatorError error; 98 // r2 = OnlinePearsonsRCalculator.Calculate(target, estVals, out error);98 //double r2 = OnlinePearsonsRCalculator.Calculate(target, estVals, out error); 99 99 //if (error != OnlineCalculatorError.None) r2 = 0.0; 100 100 … … 102 102 bool better = r2 > bestR2Result.Value; 103 103 bool equallyGood = r2.IsAlmost(bestR2Result.Value); 104 bool shorter = algorithm.BestTrainingSentence != null && symbolString.Count() < algorithm.BestTrainingSentence.Count(); 104 bool shorter = false; 105 106 if (!better && equallyGood) { 107 shorter = algorithm.BestTrainingSentence != null && 108 algorithm.Grammar.GetComplexity(algorithm.BestTrainingSentence) > algorithm.Grammar.GetComplexity(symbolString); 109 } 105 110 if (better || (equallyGood && shorter)) { 106 111 bestR2Result.Value = r2; -
branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/Analysis/SentenceLogger.cs
r15843 r15860 45 45 46 46 private void GrammarEnumerationAlgorithmOnStarted(object sender, EventArgs eventArgs) { 47 string datePostfix = $"_{DateTime.Now:yyyy-MM-dd_HH-mm}_TreeSize-{((GrammarEnumerationAlgorithm) sender).Max TreeSize}.csv";47 string datePostfix = $"_{DateTime.Now:yyyy-MM-dd_HH-mm}_TreeSize-{((GrammarEnumerationAlgorithm) sender).MaxComplexity}.csv"; 48 48 distinctSentencesFileName = workingDir + @"\distinctSentences" + datePostfix; 49 49 allSentencesFileName = workingDir + @"\allSentences" + datePostfix; -
branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/GrammarEnumeration/GrammarEnumerationAlgorithm.cs
r15843 r15860 24 24 private readonly string DistinctSentencesName = "Distinct Sentences"; 25 25 private readonly string PhraseExpansionsName = "Phrase Expansions"; 26 private readonly string AverageSentence LengthName = "Avg. Sentence Lengthamong Distinct";26 private readonly string AverageSentenceComplexityName = "Avg. Sentence Complexity among Distinct"; 27 27 private readonly string OverwrittenSentencesName = "Sentences overwritten"; 28 28 private readonly string AnalyzersParameterName = "Analyzers"; … … 31 31 32 32 private readonly string SearchDataStructureParameterName = "Search Data Structure"; 33 private readonly string Max TreeSizeParameterName = "Max. Tree Nodes";33 private readonly string MaxComplexityParameterName = "Max. Complexity"; 34 34 private readonly string GuiUpdateIntervalParameterName = "GUI Update Interval"; 35 35 36 36 public override bool SupportsPause { get { return false; } } 37 37 38 protected IValueParameter<IntValue> Max TreeSizeParameter {39 get { return (IValueParameter<IntValue>)Parameters[Max TreeSizeParameterName]; }40 } 41 public int Max TreeSize{42 get { return Max TreeSizeParameter.Value.Value; }43 set { Max TreeSizeParameter.Value.Value = value; }38 protected IValueParameter<IntValue> MaxComplexityParameter { 39 get { return (IValueParameter<IntValue>)Parameters[MaxComplexityParameterName]; } 40 } 41 public int MaxComplexity { 42 get { return MaxComplexityParameter.Value.Value; } 43 set { MaxComplexityParameter.Value.Value = value; } 44 44 } 45 45 … … 71 71 #endregion 72 72 73 public Dictionary<int, int> DistinctSentences Length{ get; private set; } // Semantically distinct sentences and their length in a run.73 public Dictionary<int, int> DistinctSentencesComplexity { get; private set; } // Semantically distinct sentences and their length in a run. 74 74 public HashSet<int> ArchivedPhrases { get; private set; } 75 75 internal SearchDataStore OpenPhrases { get; private set; } // Stack/Queue/etc. for fetching the next node in the search tree. … … 97 97 }; 98 98 99 Parameters.Add(new ValueParameter<IntValue>(Max TreeSizeParameterName, "The number of clusters.", new IntValue(6)));99 Parameters.Add(new ValueParameter<IntValue>(MaxComplexityParameterName, "The maximum number of variable symbols in a sentence.", new IntValue(5))); 100 100 Parameters.Add(new ValueParameter<IntValue>(GuiUpdateIntervalParameterName, "Number of generated sentences, until GUI is refreshed.", new IntValue(100000))); 101 101 Parameters.Add(new ValueParameter<EnumValue<StorageType>>(SearchDataStructureParameterName, new EnumValue<StorageType>(StorageType.Stack))); … … 127 127 ArchivedPhrases = new HashSet<int>(); 128 128 129 DistinctSentences Length= new Dictionary<int, int>();129 DistinctSentencesComplexity = new Dictionary<int, int>(); 130 130 AllGeneratedSentencesCount = 0; 131 131 OverwrittenSentencesCount = 0; … … 159 159 160 160 SymbolString newPhrase = currPhrase.DerivePhrase(nonterminalSymbolIndex, appliedProductions[i]); 161 162 if (newPhrase.Count() <= MaxTreeSize) { 161 int newPhraseComplexity = Grammar.GetComplexity(newPhrase); 162 163 if (newPhraseComplexity <= MaxComplexity) { 163 164 var phraseHash = Grammar.Hasher.CalcHashCode(newPhrase); 164 165 … … 170 171 OnSentenceGenerated(fetchedPhrase.Hash, fetchedPhrase.SymbolString, phraseHash, newPhrase, expandedSymbol, appliedProductions[i]); 171 172 172 if (!DistinctSentences Length.ContainsKey(phraseHash) || DistinctSentencesLength[phraseHash] > newPhrase.Count()) {173 if (DistinctSentences Length.ContainsKey(phraseHash)) OverwrittenSentencesCount++; // for analysis only174 175 DistinctSentences Length[phraseHash] = newPhrase.Count();173 if (!DistinctSentencesComplexity.ContainsKey(phraseHash) || DistinctSentencesComplexity[phraseHash] > newPhraseComplexity) { 174 if (DistinctSentencesComplexity.ContainsKey(phraseHash)) OverwrittenSentencesCount++; // for analysis only 175 176 DistinctSentencesComplexity[phraseHash] = newPhraseComplexity; 176 177 OnDistinctSentenceGenerated(fetchedPhrase.Hash, fetchedPhrase.SymbolString, phraseHash, newPhrase, expandedSymbol, appliedProductions[i]); 177 178 } … … 196 197 Results.Add(new Result(PhraseExpansionsName, new IntValue(0))); 197 198 Results.Add(new Result(OverwrittenSentencesName, new IntValue(0))); 198 Results.Add(new Result(AverageSentence LengthName, new DoubleValue(1.0)));199 Results.Add(new Result(AverageSentenceComplexityName, new DoubleValue(1.0))); 199 200 Results.Add(new Result(ExpansionsPerSecondName, "In Thousand expansions per second", new IntValue(0))); 200 201 } … … 209 210 ((IntValue)Results[SearchStructureSizeName].Value).Value = OpenPhrases.Count; 210 211 ((IntValue)Results[GeneratedSentencesName].Value).Value = AllGeneratedSentencesCount; 211 ((IntValue)Results[DistinctSentencesName].Value).Value = DistinctSentences Length.Count;212 ((IntValue)Results[DistinctSentencesName].Value).Value = DistinctSentencesComplexity.Count; 212 213 ((IntValue)Results[PhraseExpansionsName].Value).Value = PhraseExpansionCount; 213 ((DoubleValue)Results[AverageSentence LengthName].Value).Value = DistinctSentencesLength.Select(pair => pair.Value).Average();214 ((DoubleValue)Results[AverageSentenceComplexityName].Value).Value = DistinctSentencesComplexity.Select(pair => pair.Value).Average(); 214 215 ((IntValue)Results[OverwrittenSentencesName].Value).Value = OverwrittenSentencesCount; 215 216 ((IntValue)Results[ExpansionsPerSecondName].Value).Value = (int)((PhraseExpansionCount /
Note: See TracChangeset
for help on using the changeset viewer.