public string writeXTable(string outModelPath) { if (gConf == null) { buildModel(); } string outPath = outModelPath;//outDirectory + "\\" + ((IDataset)InTable).BrowseName + "_xt.xtb"; using (System.IO.StreamWriter sw = new System.IO.StreamWriter(outPath)) { sw.WriteLine(modelTypes.Accuracy.ToString()); sw.WriteLine(String.Join(",", ClassFieldNames)); sw.WriteLine(String.Join(",", labels.ToArray())); sw.WriteLine(Overall.ToString()); sw.WriteLine(Kappa.ToString()); sw.WriteLine(STE.ToString()); int rws = xtable.GetUpperBound(1); int clms = xtable.GetUpperBound(0); for (int r = 0; r <= rws; r++) { string[] ln = new string[clms + 1]; for (int c = 0; c <= clms; c++) { ln[c] = xtable[c, r].ToString(); } sw.WriteLine(String.Join(" ", ln)); } sw.Close(); } return(outPath); }
public void getReport(double alpha) { if (gConf == null) { buildModel(); } Forms.RunningProcess.frmRunningProcessDialog rd = new Forms.RunningProcess.frmRunningProcessDialog(false); rd.Text = "Accuracy Assessment"; rd.TopLevel = true; rd.pgbProcess.Visible = false; rd.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable; string[] hd = new string[labels.Count]; for (int i = 0; i < hd.Length; i++) { string s = labels[i]; if (s.Length > 4) { hd[i] = s.Substring(0, 4); } else { hd[i] = s.PadRight(3); } } rd.addMessage(" " + String.Join(" ", hd)); rd.addMessage("------".PadRight((labels.Count + 1) * 7, '-')); for (int i = 0; i < labels.Count; i++) { string[] lnArr = new string[labels.Count + 1]; string vl = labels[i]; if (vl.Length > 4) { vl = vl.Substring(0, 4); } else { vl = vl.PadRight(4); } lnArr[0] = vl; for (int j = 0; j < labels.Count; j++) { vl = xtable[i, j].ToString(); if (vl.Length < 4) { vl = vl.PadRight(4); } lnArr[j + 1] = vl; } rd.addMessage(String.Join(" | ", lnArr) + "|"); rd.addMessage("------".PadRight((labels.Count + 1) * 7, '-')); } Accord.Statistics.Testing.ChiSquareTest ct = new Accord.Statistics.Testing.ChiSquareTest(ChiSquare, System.Convert.ToInt32(Math.Pow(labels.Count - 1, 2))); rd.addMessage("Chi-square = " + ChiSquare + " DF = " + ct.DegreesOfFreedom.ToString() + " p-value = " + ct.PValue.ToString()); rd.addMessage("Overall = " + Overall.ToString()); rd.addMessage("Kappa = " + Kappa.ToString()); rd.addMessage("STE = " + STE.ToString()); ci conf = getConfidenceInterval(alpha); rd.addMessage("Kappa CI = " + conf.LowerBound.ToString() + " - " + conf.UpperBound.ToString()); rd.addMessage("Cohen Kappa Variance = " + CohenKappaVariance.ToString()); rd.Show(); rd.enableClose(); }