Changeset 14943
- Timestamp:
- 05/05/17 20:27:21 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionResidualAnalysisView.cs
r14889 r14943 22 22 using System.Drawing; 23 23 using System.Linq; 24 using System.Runtime.Remoting.Contexts;25 using System.Threading.Tasks;26 24 using HeuristicLab.Data; 27 25 using HeuristicLab.MainForm; … … 31 29 [View("Residual Analysis")] 32 30 [Content(typeof(IRegressionSolution))] 33 public partial class RegressionSolutionResidualAnalysisView : DataAnalysisSolutionEvaluationView { 31 public sealed partial class RegressionSolutionResidualAnalysisView : DataAnalysisSolutionEvaluationView { 32 33 // names should be relatively save to prevent collisions with variable names in the dataset 34 private const string PredictionLabel = "> Prediction"; 35 private const string ResidualLabel = "> Residual"; 36 private const string AbsResidualLabel = "> Residual (abs.)"; 37 private const string RelativeErrorLabel = "> Relative Error"; 38 private const string AbsRelativeErrorLabel = "> Relative Error (abs.)"; 39 private const string PartitionLabel = "> Partition"; 34 40 35 41 public new IRegressionSolution Content { 36 42 get { return (IRegressionSolution)base.Content; } 37 set { 38 base.Content = value; 39 } 43 set { base.Content = value; } 40 44 } 41 45 42 public RegressionSolutionResidualAnalysisView() 43 : base() { 46 public RegressionSolutionResidualAnalysisView() : base() { 44 47 InitializeComponent(); 45 48 } … … 58 61 } 59 62 60 pr otected virtualvoid Content_ProblemDataChanged(object sender, EventArgs e) {63 private void Content_ProblemDataChanged(object sender, EventArgs e) { 61 64 OnContentChanged(); 62 65 } 63 66 64 pr otected virtualvoid Content_ModelChanged(object sender, EventArgs e) {67 private void Content_ModelChanged(object sender, EventArgs e) { 65 68 OnContentChanged(); 66 69 } … … 86 89 var predictedValuesTrain = Content.EstimatedTrainingValues.ToArray(); 87 90 int j = 0; // idx for predictedValues array 88 var partitionId = "Partition";89 while (ds.VariableNames.Contains(partitionId)) partitionId += "_";90 91 foreach (var i in problemData.TrainingIndices) { 91 92 var run = CreateRunForIdx(i, problemData); 92 93 var targetValue = ds.GetDoubleValue(problemData.TargetVariable, i); 93 94 AddErrors(run, predictedValuesTrain[j++], targetValue); 94 run.Results.Add( partitionId, new StringValue("Training"));95 run.Results.Add(PartitionLabel, new StringValue("Training")); 95 96 run.Color = Color.Gold; 96 97 runs.Add(run); … … 102 103 var targetValue = ds.GetDoubleValue(problemData.TargetVariable, i); 103 104 AddErrors(run, predictedValuesTest[j++], targetValue); 104 run.Results.Add( partitionId, new StringValue("Test"));105 run.Results.Add(PartitionLabel, new StringValue("Test")); 105 106 run.Color = Color.Red; 106 107 runs.Add(run); … … 119 120 var residual = target - pred; 120 121 var relError = residual / target; 121 var predId = "Prediction"; 122 while (run.Results.ContainsKey(predId)) predId += "_"; 123 var resId = "Residual"; 124 while (run.Results.ContainsKey(resId)) resId += "_"; 125 var relErrorId = "Rel. Error"; 126 while (run.Results.ContainsKey(relErrorId)) relErrorId+= "_"; 127 run.Results.Add(predId, new DoubleValue(pred)); 128 run.Results.Add(resId, new DoubleValue(residual)); 129 run.Results.Add(relErrorId, new DoubleValue(relError)); 122 run.Results.Add(PredictionLabel, new DoubleValue(pred)); 123 run.Results.Add(ResidualLabel, new DoubleValue(residual)); 124 run.Results.Add(AbsResidualLabel, new DoubleValue(Math.Abs(residual))); 125 run.Results.Add(RelativeErrorLabel, new DoubleValue(relError)); 126 run.Results.Add(AbsRelativeErrorLabel, new DoubleValue(Math.Abs(relError))); 130 127 } 131 128
Note: See TracChangeset
for help on using the changeset viewer.