public void DisplayMINE(List<double>[] ListValueDesc) { int NumDesc = ListValueDesc.Length; double[,] CorrelationMatrix = new double[NumDesc, NumDesc]; double[][] dataset1 = new double[NumDesc][]; string[] VarNames = new string[NumDesc]; for (int iDesc = 0; iDesc < NumDesc; iDesc++) { dataset1[iDesc] = new double[ListValueDesc[iDesc].Count]; Array.Copy(ListValueDesc[iDesc].ToArray(), dataset1[iDesc], ListValueDesc[iDesc].Count); VarNames[iDesc] = iDesc.ToString(); } data.Dataset data1 = new data.Dataset(dataset1, VarNames, 0); VarPairQueue Qu = new VarPairQueue(data1); for (int iDesc = 0; iDesc < NumDesc; iDesc++) for (int jDesc = 0; jDesc < iDesc; jDesc++) { Qu.addPair(iDesc, jDesc); } Analysis ana = new Analysis(data1, Qu); AnalysisParameters param = new AnalysisParameters(); double resparam = param.commonValsThreshold; // analysis.results.FullResult Full = new analysis.results.FullResult(); //List<analysis.results.BriefResult> Brief = new List<analysis.results.BriefResult>(); //analysis.results.BriefResult Brief = new analysis.results.BriefResult(); java.lang.Class t = java.lang.Class.forName("analysis.results.BriefResult"); //java.lang.Class restype = null; ana.analyzePairs(t, param); // object o = (ana.varPairQueue().peek()); // ana.getClass(); // int resNum = ana.numResults(); analysis.results.Result[] res = ana.getSortedResults(); List<string[]> ListValues = new List<string[]>(); List<string> NameX = CompleteScreening.ListDescriptors.GetListNameActives(); List<bool> ListIscolor = new List<bool>(); for (int Idx = 0; Idx < res.Length; Idx++) { ListValues.Add(res[Idx].toString().Split(',')); ListValues[Idx][0] = NameX[int.Parse(ListValues[Idx][0])]; ListValues[Idx][1] = NameX[int.Parse(ListValues[Idx][1])]; } string[] ListNames = res[0].getHeader().Split(','); ListNames[0] = "Descriptor A"; ListNames[1] = "Descriptor B"; for (int NIdx = 0; NIdx < ListNames.Length; NIdx++) { if (NIdx == 0) ListIscolor.Add(false); else if (NIdx == 1) ListIscolor.Add(false); else ListIscolor.Add(true); } cDisplayTable DisplayForTable = new cDisplayTable("MINE Analysis results", ListNames, ListValues, GlobalInfo, true); }
private double[,] ComputeCorrelationMatrix(List<double>[] ListValueDesc) { int NumDesc = ListValueDesc.Length; double[,] CorrelationMatrix = new double[NumDesc, NumDesc]; if (GlobalInfo.OptionsWindow.radioButtonMIC.Checked) { double[][] dataset1 = new double[NumDesc][]; string[] VarNames = new string[NumDesc]; for (int iDesc = 0; iDesc < NumDesc; iDesc++) { dataset1[iDesc] = new double[ListValueDesc[iDesc].Count]; Array.Copy(ListValueDesc[iDesc].ToArray(), dataset1[iDesc], ListValueDesc[iDesc].Count); VarNames[iDesc] = iDesc.ToString(); } data.Dataset data1 = new data.Dataset(dataset1, VarNames, 0); VarPairQueue Qu = new VarPairQueue(data1); for (int iDesc = 0; iDesc < NumDesc; iDesc++) for (int jDesc = 0; jDesc < NumDesc; jDesc++) { Qu.addPair(iDesc, jDesc); } Analysis ana = new Analysis(data1, Qu); AnalysisParameters param = new AnalysisParameters(); double resparam = param.commonValsThreshold; analysis.results.FullResult Full = new analysis.results.FullResult(); //List<analysis.results.BriefResult> Brief = new List<analysis.results.BriefResult>(); analysis.results.BriefResult Brief = new analysis.results.BriefResult(); java.lang.Class t = java.lang.Class.forName("analysis.results.BriefResult"); //java.lang.Class restype = null; ana.analyzePairs(t, param); // object o = (ana.varPairQueue().peek()); // ana.getClass(); // int resNum = ana.numResults(); analysis.results.Result[] res = ana.getSortedResults(); // double main = res[0].getMainScore(); for (int iDesc = 0; iDesc < NumDesc; iDesc++) for (int jDesc = 0; jDesc < NumDesc; jDesc++) { int X = int.Parse(res[jDesc + iDesc * NumDesc].getXVar()); int Y = int.Parse(res[jDesc + iDesc * NumDesc].getYVar()); CorrelationMatrix[X, Y] = res[jDesc + iDesc * NumDesc].getMainScore(); } } else { //return null; for (int iDesc = 0; iDesc < NumDesc; iDesc++) for (int jDesc = 0; jDesc < NumDesc; jDesc++) { try { if (GlobalInfo.OptionsWindow.radioButtonPearson.Checked) CorrelationMatrix[iDesc, jDesc] = (alglib.pearsoncorr2(ListValueDesc[iDesc].ToArray(), ListValueDesc[jDesc].ToArray())); else if (GlobalInfo.OptionsWindow.radioButtonSpearman.Checked) CorrelationMatrix[iDesc, jDesc] = (alglib.spearmancorr2(ListValueDesc[iDesc].ToArray(), ListValueDesc[jDesc].ToArray())); } catch { //Console.WriteLine("Input string is not a sequence of digits."); return null; } } } return CorrelationMatrix; }