} /* ExploreMatrixCell */ public void MakePrediction(PicesClass knownClass, PicesClass predictedClass, double predProb, PicesFeatureVector fv, TrainingModel2 trainModel ) { bool partOfOriginalClassifier = ClassInClassifierClasses(knownClass); if (!partOfOriginalClassifier) { String notPartClassName = "(V)" + knownClass.Name; knownClass = PicesClassList.GetUniqueClass(notPartClassName, ""); } int x = classes.LookUpIndex(knownClass); if (x < 0) { classes.Add(knownClass); } x = classes.LookUpIndex(predictedClass); if (x < 0) { classes.Add(predictedClass); } Prediction p = new Prediction(knownClass, predictedClass, predProb, fv, trainModel, partOfOriginalClassifier); predictions.Add(p); } /* featureVector */
private PicesClassList SortIntoDisplayOrder(PicesClassList l) { PicesClassList knownClasses = new PicesClassList(); PicesClassList unKnownClasses = new PicesClassList(); foreach (PicesClass pc in l) { if (ClassInClassifierClasses(pc)) { knownClasses.Add(pc); } else { unKnownClasses.Add(pc); } } knownClasses.SortByName(); unKnownClasses.SortByName(); foreach (PicesClass pc in unKnownClasses) { knownClasses.Add(pc); } return(knownClasses); }
} /* ReportByClassCollumns */ private PicesClassList BuildMLClassList() { PicesClassList mlClasses = new PicesClassList(); int cIDX; //for (cIDX = 0; cIDX < totals->end (); cIDX++) for (cIDX = 0; cIDX < totals.Count; cIDX++) { ClassTotals ct = totals[cIDX]; mlClasses.Add(PicesClassList.GetUniqueClass(ct.Name, "")); } mlClasses.SortByName(); return(mlClasses); } /* BuildMLClassList */
private void PopulateMatrix() { int x, y; Font normFont = new Font("Courier", 8, FontStyle.Regular); Font boldFont = new Font("Courier", 10, FontStyle.Bold); Matrix.Items.Clear(); Matrix.Columns.Clear(); Matrix.Columns.Add("ClassName", 135, HorizontalAlignment.Left); Matrix.Columns.Add("Count", 60, HorizontalAlignment.Center); matrixRowClassAssigned = new PicesClassList(); foreach (PicesClass c in classesPredLevel) { Size textSize = TextRenderer.MeasureText(c.Name, Matrix.Font); int width = Math.Max(65, (textSize.Width + 6)); Matrix.Columns.Add(c.Name, width, HorizontalAlignment.Center); } for (x = 0; x < numPredClasses; x++) { PicesClass c = classesPredLevel[x]; bool okToDisplayThisRow = false; if (knownClassCounts[x] != 0) { okToDisplayThisRow = true; } else { for (y = 0; y < numPredClasses; y++) { if (predictionCounts[x][y] != 0) { okToDisplayThisRow = true; break; } } } if (okToDisplayThisRow) { // Matrix.I ListViewItem lvi = new ListViewItem(c.Name); //lvi.SubItems.Add (c.Name); lvi.SubItems.Add(MatrixFieldStr(knownClassCounts[x], totalCount)); for (y = 0; y < numPredClasses; y++) { String field = MatrixFieldStr(predictionCounts[x][y], knownClassCounts[x]); if (x == y) { if (ClassInClassifierClasses(c)) { lvi.SubItems.Add(field, Color.Green, Color.White, boldFont); } else { lvi.SubItems.Add(field + 'v', Color.Olive, Color.White, boldFont); } } else { if (predictionCounts[x][y] == 0) { lvi.SubItems.Add("", Color.Black, Color.White, normFont); } else { lvi.SubItems.Add(field, Color.Black, Color.White, normFont); } } } lvi.UseItemStyleForSubItems = false; Matrix.Items.Add(lvi); matrixRowClassAssigned.Add(c); } } { // Lets print a Total Line. // Matrix.I ListViewItem lvi = new ListViewItem("Totals"); //lvi.SubItems.Add (c.Name); lvi.SubItems.Add(MatrixFieldStr(totalCount, totalCount)); for (y = 0; y < numPredClasses; y++) { String field = MatrixFieldStr(predClassCounts [y], totalCount); lvi.SubItems.Add(field, Color.Black, Color.White, boldFont); } lvi.UseItemStyleForSubItems = false; Matrix.Items.Add(lvi); } ComputeSumaryAccuracies(); TotalAll.Text = totalCount.ToString("###,##0"); CorrectAll.Text = totalCorrect.ToString("###,##0.00"); AccuracyAll.Text = accuracyAll.ToString("P2"); AccuracyAll_NPC.Text = accuracyAllNPC.ToString("P2"); TotalPartOfClassifier.Text = totalPartOfClassifier.ToString("###,##0"); CorrectPartOfClassifier.Text = totalPartOfClassifierCorrect.ToString("###,##0.00"); AccuracyPartOfClassifier.Text = accuracyPartOfClass.ToString("P2"); AccuracyPartOfClassifier_NPC.Text = accuracyPartOfClassNPC.ToString("P2"); TotalNoise2.Text = totalNoise.ToString("###,##0"); CorrectNoise2.Text = totalNoiseCorrect.ToString("###,##0.00"); AccuracyNoise2.Text = accuracyNoise.ToString("P2"); AccuracyNoise2_NPC.Text = accuracyNoiseNPC.ToString("P2"); TotalNonNoise2.Text = totalNonNoise.ToString("###,##0"); CorrectNonNoise.Text = totalNonNoiseCorrect.ToString("###,##0.00"); AccuracyNonNoise.Text = accuracyNonNoise.ToString("P2"); AccuracyNonNoise_NPC.Text = accuracyNonNoiseNPC.ToString("P2"); } /* PopulateMatrix */