Changeset 12891 for branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/TreeMatching
- Timestamp:
- 08/22/15 14:27:37 (9 years ago)
- Location:
- branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic
- Property svn:mergeinfo changed
-
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/TreeMatching/SymbolicExpressionTreeBottomUpSimilarityCalculator.cs
r12287 r12891 1 1 #region License Information 2 2 3 /* HeuristicLab 3 4 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) … … 18 19 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>. 19 20 */ 20 #endregion 21 22 #endregion License Information 21 23 22 24 using System; … … 32 34 33 35 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { 36 34 37 [StorableClass] 35 38 [Item("SymbolicExpressionTreeBottomUpSimilarityCalculator", "A similarity calculator which uses the tree bottom-up distance as a similarity metric.")] … … 37 40 private readonly HashSet<string> commutativeSymbols = new HashSet<string> { "Addition", "Multiplication", "Average", "And", "Or", "Xor" }; 38 41 39 public SymbolicExpressionTreeBottomUpSimilarityCalculator() { } 42 public SymbolicExpressionTreeBottomUpSimilarityCalculator() { 43 } 44 40 45 protected override bool IsCommutative { get { return true; } } 41 46 … … 107 112 108 113 // at this point we know that v and w are isomorphic, however, the mapping cannot be done directly 109 // (as in the paper) because the trees are unordered (subtree order might differ). the solution is 114 // (as in the paper) because the trees are unordered (subtree order might differ). the solution is 110 115 // to sort subtrees from under commutative labels (this will work because the subtrees are isomorphic!) 111 116 // while iterating over the two subtrees -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/TreeMatching/SymbolicExpressionTreeNodeComparer.cs
r12155 r12891 18 18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>. 19 19 */ 20 #endregion 20 #endregion License Information 21 21 22 22 using System; … … 29 29 // - used for bringing subtrees to a "canonical" form when the operation allows reordering of arguments 30 30 public class SymbolicExpressionTreeNodeComparer : ISymbolicExpressionTreeNodeComparer { 31 31 32 public static int CompareNodes(ISymbolicExpressionTreeNode a, ISymbolicExpressionTreeNode b) { 32 33 var ta = a as SymbolicExpressionTreeTerminalNode; … … 69 70 } 70 71 } 71 72 72 } -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/TreeMatching/SymbolicExpressionTreePhenotypicSimilarityCalculator.cs
r12155 r12891 65 65 66 66 OnlineCalculatorError error; 67 var r2 = OnlinePearsonsRSquaredCalculator.Calculate(v1, v2, out error); 67 var r = OnlinePearsonsRCalculator.Calculate(v1, v2, out error); 68 69 var r2 = error == OnlineCalculatorError.None ? r * r : 0; 68 70 69 71 if (r2 > 1.0) 70 72 r2 = 1.0; 71 73 72 return error == OnlineCalculatorError.None ? r2 : 0;74 return r2; 73 75 } 74 76 … … 87 89 88 90 OnlineCalculatorError error; 89 var r2 = OnlinePearsonsRSquaredCalculator.Calculate(leftValues, rightValues, out error); 91 var r = OnlinePearsonsRCalculator.Calculate(leftValues, rightValues, out error); 92 93 var r2 = error == OnlineCalculatorError.None ? r * r : 0; 90 94 91 95 if (r2 > 1.0) 92 r2 = 1.0; // sometimes due to fp errors it can happen that the r2 is over 1 (like 1.0000000009)96 r2 = 1.0; 93 97 94 return error == OnlineCalculatorError.None ? r2 : 0;98 return r2; 95 99 } 96 100 }
Note: See TracChangeset
for help on using the changeset viewer.