/// <summary> /// Perform an Hierarchical clustering on each plate independantely /// </summary> /// <param name="CurrentPlateToProcess">the plate to process</param> /// <param name="ClassNumber">Number of class</param> private void ClusteringHierarchicalSinglePlate(cPlate CurrentPlateToProcess, int ClassNumber) { weka.core.Instances Ninsts = CurrentPlateToProcess.CreateInstancesWithoutClass(); weka.clusterers.HierarchicalClusterer HClusterer = new HierarchicalClusterer(); //string OptionDistance = " -A \"weka.core."; string OptionDistance = " -A \""; switch (cGlobalInfo.OptionsWindow.comboBoxHierarchicalDistance.SelectedIndex) { case 0: OptionDistance += "EuclideanDistance"; break; case 1: OptionDistance += "ManhattanDistance"; break; case 2: OptionDistance += "ChebyshevDistance"; break; default: break; } OptionDistance += " -R first-last\""; string[] TAGS_LINK_TYPE = { "SINGLE", "COMPLETE", "AVERAGE", "MEAN", "CENTROID", "WARD", "ADJCOMPLETE" }; string WekaOption = "-L " + TAGS_LINK_TYPE[cGlobalInfo.OptionsWindow.comboBoxHierarchicalLinkType.SelectedIndex];// + OptionDistance; HClusterer.setOptions(weka.core.Utils.splitOptions(WekaOption)); //EuclideanDistance2 Dist2 = new EuclideanDistance2(); //HClusterer.setDistanceFunction(Dist2); HClusterer.setNumClusters(ClassNumber); HClusterer.buildClusterer(Ninsts); richTextBoxInfoClustering.AppendText("\n" + CurrentPlateToProcess.GetName() + ": " + HClusterer.numberOfClusters() + " cluster(s)"); ClusterEvaluation eval = new ClusterEvaluation(); eval.setClusterer(HClusterer); eval.evaluateClusterer(Ninsts); CurrentPlateToProcess.AssignClass(eval.getClusterAssignments()); }
/// <summary> /// perform an Hierarchical clustering over the entire screening data /// </summary> /// <param name="ClassNumber"></param> private void ClusteringHierarchicalGlobalScreen(int ClassNumber) { weka.core.Instances Ninsts = CompleteScreening.CreateInstancesWithoutClass(); weka.clusterers.HierarchicalClusterer HClusterer = new HierarchicalClusterer(); string OptionDistance = " -A \"weka.core."; switch (GlobalInfo.OptionsWindow.comboBoxHierarchicalDistance.SelectedIndex) { case 0: OptionDistance += "EuclideanDistance"; break; case 1: OptionDistance += "ManhattanDistance"; break; case 2: OptionDistance += "ChebyshevDistance"; break; default: break; } OptionDistance += " -R first-last\""; string[] TAGS_LINK_TYPE = { "SINGLE", "COMPLETE", "AVERAGE", "MEAN", "CENTROID", "WARD", "ADJCOMPLETE" }; string WekaOption = "-L " + TAGS_LINK_TYPE[GlobalInfo.OptionsWindow.comboBoxHierarchicalLinkType.SelectedIndex] + OptionDistance; HClusterer.setOptions(weka.core.Utils.splitOptions(WekaOption)); HClusterer.setNumClusters(ClassNumber); HClusterer.buildClusterer(Ninsts); richTextBoxInfoClustering.AppendText("\n" + HClusterer.numberOfClusters() + " cluster(s) identified"); ClusterEvaluation eval = new ClusterEvaluation(); eval.setClusterer(HClusterer); eval.evaluateClusterer(Ninsts); CompleteScreening.AssignClass(eval.getClusterAssignments()); }