Changeset 8507
- Timestamp:
- 08/20/12 16:34:14 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ClassificationEnsembleVoting/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/ClassificationEnsembleSolutionAccuracyToCoveredSamples.cs
r8329 r8507 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Drawing; 24 25 using System.Linq; 25 26 using System.Windows.Forms; … … 34 35 public partial class ClassificationEnsembleSolutionAccuracyToCoveredSamples : DataAnalysisSolutionEvaluationView { 35 36 private const string ACCURACYCOVERED = "Accuracy to Covered percentage"; 37 private const string AREA = "Area"; 36 38 37 39 private const string SamplesComboBoxAllSamples = "All Samples"; … … 39 41 private const string SamplesComboBoxTestSamples = "Test Samples"; 40 42 41 // zero is also a point42 43 private const int maxPoints = 101; 43 44 … … 137 138 covered = covered.Reverse().ToArray(); 138 139 139 140 141 Series serie = this.chart.Series.Add(ACCURACYCOVERED); 142 serie.LegendText = ACCURACYCOVERED; 143 serie.ChartType = SeriesChartType.StepLine; 144 //serie.MarkerStyle = MarkerStyle.Diamond; 145 //serie.MarkerSize = 5; 146 serie.Points.DataBindXY(covered, accuracy); 140 Series area = this.chart.Series.Add(AREA); 141 area.ChartType = SeriesChartType.Area; 142 area.Color = Color.LightBlue; 143 IEnumerable<IEnumerable<double>> areaPoints = CalculateAreaPoints(covered, accuracy); 144 area.Points.DataBindXY(areaPoints.ElementAt(0), areaPoints.ElementAt(1)); 145 146 Series series = this.chart.Series.Add(ACCURACYCOVERED); 147 series.Color = Color.Red; 148 series.ChartType = SeriesChartType.FastPoint; 149 series.MarkerStyle = MarkerStyle.Diamond; 150 series.MarkerSize = 5; 151 series.Points.DataBindXY(covered, accuracy); 152 153 double auc = CalculateAreaUnderCurve(series); 154 area.LegendToolTip = "AUC: " + auc; 147 155 } 156 } 157 158 private IEnumerable<IEnumerable<double>> CalculateAreaPoints(double[] covered, double[] accuracy) { 159 List<double> newCovered = new List<double>(); 160 List<double> worseAccuracy = new List<double>(); 161 newCovered.Add(covered[0]); 162 worseAccuracy.Add(accuracy[0]); 163 for (int i = 1; i < covered.Length; i++) { 164 if (accuracy[i] > accuracy[i - 1]) { 165 worseAccuracy.Add(accuracy[i - 1]); 166 newCovered.Add(covered[i] - Double.Epsilon); 167 } else { 168 worseAccuracy.Add(accuracy[i]); 169 newCovered.Add(covered[i - 1] + Double.Epsilon); 170 } 171 worseAccuracy.Add(accuracy[i]); 172 newCovered.Add(covered[i]); 173 } 174 return new List<IEnumerable<double>>() { newCovered, worseAccuracy }; 148 175 } 149 176 … … 159 186 } 160 187 188 private double CalculateAreaUnderCurve(Series series) { 189 if (series.Points.Count < 1) throw new ArgumentException("Could not calculate area under curve if less than 1 data points were given."); 190 191 double auc = 0.0; 192 for (int i = 1; i < series.Points.Count; i++) { 193 double width = series.Points[i].XValue - series.Points[i - 1].XValue; 194 double y1 = series.Points[i - 1].YValues[0]; 195 double y2 = series.Points[i].YValues[0]; 196 197 auc += (y1 + y2) * width / 2; 198 } 199 200 return auc; 201 } 202 161 203 #region events 162 204 protected override void RegisterContentEvents() {
Note: See TracChangeset
for help on using the changeset viewer.