- Timestamp:
- 04/04/17 17:52:44 (8 years ago)
- Location:
- trunk/sources
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources
- Property svn:mergeinfo changed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification
- Property svn:mergeinfo changed
/branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification (added) merged: 14232,14237,14330,14497,14499,14591-14592
- Property svn:mergeinfo changed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SymbolicClassificationSolutionImpactValuesCalculator.cs
r14185 r14826 40 40 protected SymbolicClassificationSolutionImpactValuesCalculator(bool deserializing) : base(deserializing) { } 41 41 42 public override double CalculateReplacementValue(ISymbolicDataAnalysisModel model, ISymbolicExpressionTreeNode node, IDataAnalysisProblemData problemData, IEnumerable<int> rows) { 43 var classificationModel = (ISymbolicClassificationModel)model; 44 var classificationProblemData = (IClassificationProblemData)problemData; 45 46 return CalculateReplacementValue(node, classificationModel.SymbolicExpressionTree, classificationModel.Interpreter, classificationProblemData.Dataset, rows); 47 } 48 49 public override double CalculateImpactValue(ISymbolicDataAnalysisModel model, ISymbolicExpressionTreeNode node, IDataAnalysisProblemData problemData, IEnumerable<int> rows, double qualityForImpactsCalculation = double.NaN) { 50 double impactValue, replacementValue; 51 double newQualityForImpactsCalculation; 52 CalculateImpactAndReplacementValues(model, node, problemData, rows, out impactValue, out replacementValue, out newQualityForImpactsCalculation, qualityForImpactsCalculation); 53 return impactValue; 54 } 55 56 public override void CalculateImpactAndReplacementValues(ISymbolicDataAnalysisModel model, ISymbolicExpressionTreeNode node, 57 IDataAnalysisProblemData problemData, IEnumerable<int> rows, out double impactValue, out double replacementValue, out double newQualityForImpactsCalculation, 42 public override void CalculateImpactAndReplacementValues(ISymbolicDataAnalysisModel model, 43 ISymbolicExpressionTreeNode node, 44 IDataAnalysisProblemData problemData, IEnumerable<int> rows, out double impactValue, out double replacementValue, 45 out double newQualityForImpactsCalculation, 58 46 double qualityForImpactsCalculation = Double.NaN) { 59 47 var classificationModel = (ISymbolicClassificationModel)model; … … 63 51 qualityForImpactsCalculation = CalculateQualityForImpacts(classificationModel, classificationProblemData, rows); 64 52 65 replacementValue = CalculateReplacementValue(classificationModel, node, classificationProblemData, rows);66 var constantNode = new ConstantTreeNode(new Constant()) { Value = replacementValue };67 53 68 54 var cloner = new Cloner(); … … 72 58 var tempModelParentNode = tempModelNode.Parent; 73 59 int i = tempModelParentNode.IndexOfSubtree(tempModelNode); 74 tempModelParentNode.RemoveSubtree(i); 75 tempModelParentNode.InsertSubtree(i, constantNode); 60 double bestReplacementValue = 0.0; 61 double bestImpactValue = double.PositiveInfinity; 62 newQualityForImpactsCalculation = qualityForImpactsCalculation; // initialize 63 // try the potentially reasonable replacement values and use the best one 64 foreach (var repValue in CalculateReplacementValues(node, classificationModel.SymbolicExpressionTree, classificationModel.Interpreter, classificationProblemData.Dataset, classificationProblemData.TrainingIndices)) { 65 tempModelParentNode.RemoveSubtree(i); 76 66 77 OnlineCalculatorError errorState; 78 var dataset = classificationProblemData.Dataset; 79 var targetClassValues = dataset.GetDoubleValues(classificationProblemData.TargetVariable, rows); 80 var estimatedClassValues = tempModel.GetEstimatedClassValues(dataset, rows); 81 newQualityForImpactsCalculation = OnlineAccuracyCalculator.Calculate(targetClassValues, estimatedClassValues, out errorState); 82 if (errorState != OnlineCalculatorError.None) newQualityForImpactsCalculation = 0.0; 67 var constantNode = new ConstantTreeNode(new Constant()) { Value = repValue }; 68 tempModelParentNode.InsertSubtree(i, constantNode); 83 69 84 impactValue = qualityForImpactsCalculation - newQualityForImpactsCalculation; 70 var dataset = classificationProblemData.Dataset; 71 var targetClassValues = dataset.GetDoubleValues(classificationProblemData.TargetVariable, rows); 72 var estimatedClassValues = tempModel.GetEstimatedClassValues(dataset, rows); 73 OnlineCalculatorError errorState; 74 newQualityForImpactsCalculation = OnlineAccuracyCalculator.Calculate(targetClassValues, estimatedClassValues, 75 out errorState); 76 if (errorState != OnlineCalculatorError.None) newQualityForImpactsCalculation = 0.0; 77 78 impactValue = qualityForImpactsCalculation - newQualityForImpactsCalculation; 79 80 if (impactValue < bestImpactValue) { 81 bestImpactValue = impactValue; 82 bestReplacementValue = repValue; 83 } 84 } 85 replacementValue = bestReplacementValue; 86 impactValue = bestImpactValue; 85 87 } 86 88
Note: See TracChangeset
for help on using the changeset viewer.