Changeset 15406 for stable/HeuristicLab.Problems.DataAnalysis.Symbolic
- Timestamp:
- 10/06/17 13:38:16 (7 years ago)
- Location:
- stable
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk/sources merged: 15371-15372,15390,15400,15402
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.DataAnalysis.Symbolic
- Property svn:mergeinfo changed
/branches/SimplifierViewsProgress/HeuristicLab.Problems.DataAnalysis.Symbolic (added) merged: 15318,15321 /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic merged: 15371
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisSolutionImpactValuesCalculator.cs
r15131 r15406 32 32 public abstract class SymbolicDataAnalysisSolutionImpactValuesCalculator : Item, ISymbolicDataAnalysisSolutionImpactValuesCalculator { 33 33 protected SymbolicDataAnalysisSolutionImpactValuesCalculator() { } 34 35 34 protected SymbolicDataAnalysisSolutionImpactValuesCalculator(SymbolicDataAnalysisSolutionImpactValuesCalculator original, Cloner cloner) 36 35 : base(original, cloner) { } 37 36 [StorableConstructor] 38 37 protected SymbolicDataAnalysisSolutionImpactValuesCalculator(bool deserializing) : base(deserializing) { } 39 public abstract void CalculateImpactAndReplacementValues(ISymbolicDataAnalysisModel model, ISymbolicExpressionTreeNode node, IDataAnalysisProblemData problemData, IEnumerable<int> rows, out double impactValue, out double replacementValue, out double newQualityForImpactsCalculation, double qualityForImpactsCalculation = double.NaN); 38 39 public virtual void CalculateImpactAndReplacementValues(ISymbolicDataAnalysisModel model, ISymbolicExpressionTreeNode node, IDataAnalysisProblemData problemData, IEnumerable<int> rows, 40 out double impactValue, out double replacementValue, out double newQualityForImpactsCalculation, 41 double qualityForImpactsCalculation = double.NaN) { 42 if (double.IsNaN(qualityForImpactsCalculation)) 43 qualityForImpactsCalculation = CalculateQualityForImpacts(model, problemData, rows); 44 45 var cloner = new Cloner(); 46 var tempModel = cloner.Clone(model); 47 var tempModelNode = (ISymbolicExpressionTreeNode)cloner.GetClone(node); 48 49 var tempModelParentNode = tempModelNode.Parent; 50 int i = tempModelParentNode.IndexOfSubtree(tempModelNode); 51 52 double bestReplacementValue = 0.0; 53 double bestImpactValue = double.PositiveInfinity; 54 newQualityForImpactsCalculation = qualityForImpactsCalculation; // initialize 55 // try the potentially reasonable replacement values and use the best one 56 foreach (var repValue in CalculateReplacementValues(node, model.SymbolicExpressionTree, model.Interpreter, problemData.Dataset, problemData.TrainingIndices)) { 57 tempModelParentNode.RemoveSubtree(i); 58 59 var constantNode = new ConstantTreeNode(new Constant()) { Value = repValue }; 60 tempModelParentNode.InsertSubtree(i, constantNode); 61 62 newQualityForImpactsCalculation = CalculateQualityForImpacts(tempModel, problemData, rows); 63 64 impactValue = qualityForImpactsCalculation - newQualityForImpactsCalculation; 65 if (impactValue < bestImpactValue) { 66 bestImpactValue = impactValue; 67 bestReplacementValue = repValue; 68 } 69 } 70 71 replacementValue = bestReplacementValue; 72 impactValue = bestImpactValue; 73 } 74 75 protected abstract double CalculateQualityForImpacts(ISymbolicDataAnalysisModel model, IDataAnalysisProblemData problemData, IEnumerable<int> rows); 40 76 41 77 protected IEnumerable<double> CalculateReplacementValues(ISymbolicExpressionTreeNode node, ISymbolicExpressionTree sourceTree, ISymbolicDataAnalysisExpressionTreeInterpreter interpreter,
Note: See TracChangeset
for help on using the changeset viewer.