public void writeModel(string outModel) { if (pDic.Count == 0) { buildModel(); } using (System.IO.StreamWriter sw = new System.IO.StreamWriter(outModel)) { sw.WriteLine(dataPrepBase.modelTypes.KS.ToString()); sw.WriteLine(String.Join(",", Variables)); sw.WriteLine(StrataField); sw.WriteLine(Oridinate.ToString()); string[] lbl = Labels; sw.WriteLine(String.Join(",", lbl)); string[] pArr = new string[lbl.Length]; string[] sArr = new string[lbl.Length]; string[] cArr1 = new string[lbl.Length]; string[] cArr2 = new string[lbl.Length]; double[][] minmax1, minmax2, bp1, bp2; for (int i = 0; i < lbl.Length; i++) { string l = lbl[i]; pArr[i] = String.Join(";", (from double d in pDic[l] select d.ToString()).ToArray()); sArr[i] = String.Join(";", (from double d in sDic[l] select d.ToString()).ToArray()); int[] cArr = cntDic[l]; cArr1[i] = cArr[0].ToString(); cArr2[i] = cArr[1].ToString(); } sw.WriteLine(String.Join(",", pArr)); sw.WriteLine(String.Join(",", sArr)); sw.WriteLine(String.Join(",", cArr1)); sw.WriteLine(String.Join(",", cArr2)); for (int i = 0; i < lbl.Length; i++) { string l = lbl[i]; minmax1 = minMaxDic1[l]; minmax2 = minMaxDic2[l]; sw.WriteLine(String.Join(",", (from double d in minmax1[0] select d.ToString()).ToArray())); sw.WriteLine(String.Join(",", (from double d in minmax1[1] select d.ToString()).ToArray())); sw.WriteLine(String.Join(",", (from double d in minmax2[0] select d.ToString()).ToArray())); sw.WriteLine(String.Join(",", (from double d in minmax2[1] select d.ToString()).ToArray())); bp1 = binPropDic1[l]; bp2 = binPropDic2[l]; for (int j = 0; j < Variables.Length; j++) { sw.WriteLine(String.Join(",", (from double d in bp1[j] select d.ToString()).ToArray())); sw.WriteLine(String.Join(",", (from double d in bp2[j] select d.ToString()).ToArray())); } sw.WriteLine(String.Join(",", (from int d in clusCountDic[l] select d.ToString()).ToArray())); sw.WriteLine(String.Join(",", (from int d in clusSampleCountDic[l] select d.ToString()).ToArray())); } string pcaPath = System.IO.Path.GetDirectoryName(outModel) + "\\" + System.IO.Path.GetFileNameWithoutExtension(outModel) + "_pca.mdl"; pca.writeModel(pcaPath); sw.WriteLine(pcaPath); string clustPath = System.IO.Path.GetDirectoryName(outModel) + "\\" + System.IO.Path.GetFileNameWithoutExtension(outModel) + "_cluster.mdl"; cluster.writeModel(clustPath); sw.WriteLine(clustPath); sw.Close(); } }
public void getReport() { Forms.RunningProcess.frmRunningProcessDialog rd = new Forms.RunningProcess.frmRunningProcessDialog(false); rd.Text = "Kolmogorov Smirnov Two sample distribution Results (p-value for unequal distributions)"; rd.TopLevel = true; rd.pgbProcess.Visible = false; rd.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable; rd.addMessage("Vars: " + String.Join(", ", Variables)); rd.addMessage("Perform PCA " + Oridinate.ToString()); rd.addMessage("Strata Field = " + StrataField); rd.addMessage("\n Label | Statistic | WP value | WS p-value"); rd.addMessage("-".PadRight(48, '-')); for (int i = 0; i < Labels.Length; i++) { string ky = Labels[i]; double stat = StatisticValues[i]; string sVl = stat.ToString(); double vl = PValues[i]; string fVl = vl.ToString(); if (vl < 0.0001) { fVl = "p < 0.0001"; } double wVl = WSpvalues[i]; string wspStr = wVl.ToString(); if (wVl < 0.0001) { wspStr = "p < 0.0001"; } string l = ModelHelper.getValue(ky, 8); string wp = ModelHelper.getValue(fVl, 10); string s = ModelHelper.getValue(sVl, 10); string wsp = ModelHelper.getValue(wspStr, 10); rd.addMessage(l + " | " + s + " | " + wp + " | " + wsp); } rd.addMessage("-".PadRight(48, '-')); if (ModelHelper.chartingAvailable()) { createKSchart(); } rd.enableClose(); rd.Show(); }