Changeset 8863 for branches/ClassificationEnsembleVoting/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification
- Timestamp:
- 10/30/12 16:22:04 (12 years ago)
- Location:
- branches/ClassificationEnsembleVoting/HeuristicLab.Problems.DataAnalysis.Views
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ClassificationEnsembleVoting/HeuristicLab.Problems.DataAnalysis.Views
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Problems.DataAnalysis.Views merged: 8831,8833,8840,8859,8861
- Property svn:mergeinfo changed
-
branches/ClassificationEnsembleVoting/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/ClassificationEnsembleSolutionAccuracyToCoveredSamples.cs
r8862 r8863 118 118 } 119 119 120 int row; 121 for (int i = 0; i < maxPoints; i++) { 122 double confidenceValue = (1.0 / (maxPoints - 1)) * i; 123 int notCovered = 0; 124 125 for (int j = 0; j < indizes.Length; j++) { 126 row = indizes[j]; 127 if (confidences[j] >= confidenceValue) { 128 accuracyCalc.Add(target[row], estimatedClassValues[j]); 129 } else { 130 notCovered++; 120 if (!estimatedClassValues.All(x => Double.IsNaN(x))) { 121 int row; 122 for (int i = 0; i < maxPoints; i++) { 123 double confidenceValue = (1.0 / (maxPoints - 1)) * i; 124 int notCovered = 0; 125 126 for (int j = 0; j < indizes.Length; j++) { 127 row = indizes[j]; 128 if (confidences[j] >= confidenceValue) { 129 accuracyCalc.Add(target[row], estimatedClassValues[j]); 130 } else { 131 notCovered++; 132 } 131 133 } 134 135 accuracy[i + 1] = accuracyCalc.Accuracy; 136 if (indizes.Length > 0) { 137 covered[i] = 1.0 - (double)notCovered / (double)indizes.Length; 138 } 139 accuracyCalc.Reset(); 132 140 } 133 141 134 accuracy[i + 1] = accuracyCalc.Accuracy; 135 if (indizes.Length > 0) { 136 covered[i] = 1.0 - (double)notCovered / (double)indizes.Length; 137 } 138 accuracyCalc.Reset(); 142 accuracy[0] = accuracy[1]; 143 covered[maxPoints] = 0.0; 144 145 accuracy = accuracy.Reverse().ToArray(); 146 covered = covered.Reverse().ToArray(); 147 148 Series area = this.chart.Series.Add(AREA); 149 area.ChartType = SeriesChartType.Area; 150 area.Color = Color.LightBlue; 151 IEnumerable<IEnumerable<double>> areaPoints = CalculateAreaPoints(covered, accuracy); 152 area.Points.DataBindXY(areaPoints.ElementAt(0), areaPoints.ElementAt(1)); 153 154 Series series = this.chart.Series.Add(ACCURACYCOVERED); 155 series.Color = Color.Red; 156 series.ChartType = SeriesChartType.FastPoint; 157 series.MarkerStyle = MarkerStyle.Diamond; 158 series.MarkerSize = 5; 159 series.Points.DataBindXY(covered, accuracy); 160 161 double auc = CalculateAreaUnderCurve(series); 162 area.LegendToolTip = "AUC: " + auc; 163 164 AUCLabel.Text = "AUC: " + auc; 165 } else { 166 AUCLabel.Text = "No values in this partition!"; 139 167 } 140 141 accuracy[0] = accuracy[1];142 covered[maxPoints] = 0.0;143 144 accuracy = accuracy.Reverse().ToArray();145 covered = covered.Reverse().ToArray();146 147 Series area = this.chart.Series.Add(AREA);148 area.ChartType = SeriesChartType.Area;149 area.Color = Color.LightBlue;150 IEnumerable<IEnumerable<double>> areaPoints = CalculateAreaPoints(covered, accuracy);151 area.Points.DataBindXY(areaPoints.ElementAt(0), areaPoints.ElementAt(1));152 153 Series series = this.chart.Series.Add(ACCURACYCOVERED);154 series.Color = Color.Red;155 series.ChartType = SeriesChartType.FastPoint;156 series.MarkerStyle = MarkerStyle.Diamond;157 series.MarkerSize = 5;158 series.Points.DataBindXY(covered, accuracy);159 160 double auc = CalculateAreaUnderCurve(series);161 area.LegendToolTip = "AUC: " + auc;162 163 AUCLabel.Text = "AUC: " + auc;164 168 } 165 169 } -
branches/ClassificationEnsembleVoting/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/ClassificationEnsembleSolutionEstimatedClassValuesView.cs
r8814 r8863 133 133 int row = indizes[i]; 134 134 values[i, 0] = row.ToString(); 135 values[i, 1] = target[ i].ToString();135 values[i, 1] = target[row].ToString(); 136 136 //display only indices and target values if no models are present 137 137 if (solutionsCount > 0) { 138 138 values[i, 2] = estimatedClassValues[i].ToString(); 139 correctClassified = target[ i].IsAlmost(estimatedClassValues[i]);139 correctClassified = target[row].IsAlmost(estimatedClassValues[i]); 140 140 values[i, 3] = correctClassified.ToString(); 141 141 curConfidence = confidences[i]; -
branches/ClassificationEnsembleVoting/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/ClassificationFeatureCorrelationView.cs
r8811 r8863 37 37 } 38 38 39 protected override bool[] SetInitialV isibilityOfColumns() {39 protected override bool[] SetInitialVariableVisibility() { 40 40 int i = Content.Dataset.DoubleVariables.ToList().FindIndex(x => x == Content.TargetVariable); 41 var initialVisibility = base.SetInitialV isibilityOfColumns();41 var initialVisibility = base.SetInitialVariableVisibility(); 42 42 initialVisibility[i] = true; 43 43 return initialVisibility; -
branches/ClassificationEnsembleVoting/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/ClassificationTimeframeFeatureCorrelationView.cs
r8811 r8863 37 37 } 38 38 39 protected override bool[] SetInitialV isibilityOfColumns() {39 protected override bool[] SetInitialVariableVisibility() { 40 40 int i = Content.Dataset.DoubleVariables.ToList().FindIndex(x => x == Content.TargetVariable); 41 var initialVisibility = base.SetInitialV isibilityOfColumns();41 var initialVisibility = base.SetInitialVariableVisibility(); 42 42 initialVisibility[i] = true; 43 43 return initialVisibility; -
branches/ClassificationEnsembleVoting/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/DiscriminantFunctionClassificationRocCurvesView.cs
r8811 r8863 114 114 maxThreshold += thresholdIncrement; 115 115 116 List<double> classValues = Content. Model.ClassValues.ToList();116 List<double> classValues = Content.ProblemData.ClassValues.ToList(); 117 117 118 118 foreach (double classValue in classValues) { -
branches/ClassificationEnsembleVoting/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/DiscriminantFunctionClassificationSolutionThresholdView.Designer.cs
r8508 r8863 1 namespace HeuristicLab.Problems.DataAnalysis.Views { 1 using System.Windows.Forms.DataVisualization.Charting; 2 namespace HeuristicLab.Problems.DataAnalysis.Views { 2 3 partial class DiscriminantFunctionClassificationSolutionThresholdView { 3 4 /// <summary> … … 53 54 this.chart.MouseDown += new System.Windows.Forms.MouseEventHandler(this.chart_MouseDown); 54 55 this.chart.MouseMove += new System.Windows.Forms.MouseEventHandler(this.chart_MouseMove); 56 this.chart.PostPaint += new System.EventHandler<System.Windows.Forms.DataVisualization.Charting.ChartPaintEventArgs>(chart_PostPaint); 55 57 // 56 58 // JitterTrackBar … … 92 94 93 95 } 94 95 96 #endregion 96 97 -
branches/ClassificationEnsembleVoting/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/DiscriminantFunctionClassificationSolutionThresholdView.cs
r8811 r8863 40 40 private const string TestLabelText = "Test Samples"; 41 41 42 private const double ClassNameLeftOffset = 10.0; 43 private const double ClassNameBottomOffset = 5.0; 44 42 45 public new IDiscriminantFunctionClassificationSolution Content { 43 46 get { return (IDiscriminantFunctionClassificationSolution)base.Content; } … … 47 50 private Dictionary<double, Series> classValueSeriesMapping; 48 51 private Random random; 49 private bool updateInProgress ;52 private bool updateInProgress, updateThresholds; 50 53 51 54 public DiscriminantFunctionClassificationSolutionThresholdView() … … 126 129 FillSeriesWithDataPoints(series); 127 130 } 128 AddThresholds();131 updateThresholds = true; 129 132 } 130 133 chart.ChartAreas[0].RecalculateAxesScale(); … … 166 169 } 167 170 171 private void chart_PostPaint(object sender, ChartPaintEventArgs e) { 172 if (updateThresholds) { 173 AddThresholds(); 174 updateThresholds = false; 175 } 176 } 177 168 178 private void AddThresholds() { 169 179 chart.Annotations.Clear(); 170 180 int classIndex = 1; 181 SizeF textSizeInPixel; 182 IClassificationProblemData problemData = Content.ProblemData; 183 var classValues = Content.Model.ClassValues.ToArray(); 184 Graphics g = chart.CreateGraphics(); 185 Axis y = chart.ChartAreas[0].AxisY; 186 Axis x = chart.ChartAreas[0].AxisX; 187 string name; 171 188 foreach (double threshold in Content.Model.Thresholds) { 172 189 if (!double.IsInfinity(threshold)) { … … 176 193 annotation.LineWidth = 2; 177 194 annotation.LineColor = Color.Red; 178 179 195 annotation.IsInfinitive = true; 180 196 annotation.ClipToChartArea = chart.ChartAreas[0].Name; 181 197 annotation.Tag = classIndex; //save classIndex as Tag to avoid moving the threshold accross class bounderies 182 183 198 annotation.AxisX = chart.ChartAreas[0].AxisX; 184 annotation.AxisY = chart.ChartAreas[0].AxisY;199 annotation.AxisY = y; 185 200 annotation.Y = threshold; 186 201 202 name = problemData.GetClassName(classValues[classIndex - 1]); 203 TextAnnotation beneathLeft = CreateTextAnnotation(name, classIndex, x, y); 204 beneathLeft.Y = threshold; 205 beneathLeft.X = x.Minimum; 206 TextAnnotation beneathRigth = CreateTextAnnotation(name, classIndex, x, y); 207 beneathRigth.Y = threshold; 208 textSizeInPixel = g.MeasureString(beneathRigth.Text, beneathRigth.Font); 209 double textWidthPixelPos = x.ValueToPixelPosition(x.Maximum) - textSizeInPixel.Width - ClassNameLeftOffset; 210 //check if position is within the position boundary 211 beneathRigth.X = textWidthPixelPos < 0 || textWidthPixelPos > chart.Width ? double.NaN : x.PixelPositionToValue(textWidthPixelPos); 212 213 name = problemData.GetClassName(classValues[classIndex]); 214 TextAnnotation aboveLeft = CreateTextAnnotation(name, classIndex, x, y); 215 textSizeInPixel = g.MeasureString(aboveLeft.Text, aboveLeft.Font); 216 double textHeightPixelPos = y.ValueToPixelPosition(threshold) - textSizeInPixel.Height - ClassNameBottomOffset; 217 //check if position is within the position boundary 218 aboveLeft.Y = textHeightPixelPos < 0 || textHeightPixelPos > chart.Height ? double.NaN : y.PixelPositionToValue(textHeightPixelPos); 219 aboveLeft.X = x.Minimum; 220 TextAnnotation aboveRight = CreateTextAnnotation(name, classIndex, x, y); 221 aboveRight.Y = aboveLeft.Y; 222 textWidthPixelPos = x.ValueToPixelPosition(x.Maximum) - textSizeInPixel.Width - ClassNameLeftOffset; 223 //check if position is within the position boundary 224 aboveRight.X = textWidthPixelPos < 0 || textWidthPixelPos > chart.Width ? double.NaN : x.PixelPositionToValue(textWidthPixelPos); 225 187 226 chart.Annotations.Add(annotation); 227 chart.Annotations.Add(beneathLeft); 228 chart.Annotations.Add(aboveLeft); 229 chart.Annotations.Add(beneathRigth); 230 chart.Annotations.Add(aboveRight); 188 231 classIndex++; 189 232 } 190 233 } 234 } 235 236 private TextAnnotation CreateTextAnnotation(string name, int classIndex, Axis x, Axis y) { 237 TextAnnotation annotation = new TextAnnotation(); 238 annotation.Text = name; 239 annotation.AllowMoving = true; 240 annotation.AllowResizing = false; 241 annotation.AllowSelecting = false; 242 annotation.ClipToChartArea = chart.ChartAreas[0].Name; 243 annotation.Tag = classIndex; 244 annotation.AxisX = chart.ChartAreas[0].AxisX; 245 annotation.AxisY = y; 246 return annotation; 191 247 } 192 248
Note: See TracChangeset
for help on using the changeset viewer.