public void PerformScreeningClustering(List<cPlate> ListPlatesToProcess, bool IsOneByOne) { this.Cursor = Cursors.WaitCursor; cMachineLearning MachineLearning = new cMachineLearning(this.GlobalInfo); cParamAlgo ParamAlgoForClustering = MachineLearning.AskAndGetClusteringAlgo(); if (ParamAlgoForClustering == null) { this.Cursor = Cursors.Default; return; } //DataTable dt = new DataTable(); cExtendedTable dt = new cExtendedTable(); for (int IdxDesc = 0; IdxDesc < cGlobalInfo.CurrentScreening.ListDescriptors.Count; IdxDesc++) { if (cGlobalInfo.CurrentScreening.ListDescriptors[IdxDesc].IsActive()) dt.Add(new cExtendedList(cGlobalInfo.CurrentScreening.ListDescriptors[IdxDesc].GetName())); } if (IsOneByOne) { foreach (cPlate itemPlate in ListPlatesToProcess) { cListWells ListWell = new cListWells(null); foreach (var item in itemPlate.ListActiveWells) ListWell.Add(item); dt = ListWell.GetAverageDescriptorValues(cGlobalInfo.CurrentScreening.ListDescriptors.GetActiveDescriptors(), false, false); MachineLearning.SelectedClusterer = MachineLearning.BuildClusterer(ParamAlgoForClustering, dt); if (MachineLearning.SelectedClusterer != null) { double[] Assign = MachineLearning.EvaluteAndDisplayClusterer(richTextBoxInfoClustering, null, MachineLearning.CreateInstancesWithoutClass(dt)).getClusterAssignments(); MachineLearning.Classes = new cExtendedList(); MachineLearning.Classes.AddRange(Assign); } if (MachineLearning.Classes.Max() >= cGlobalInfo.ListWellClasses.Count) { MessageBox.Show("The number of clusters is higher than the supported number of classes. Operation cancelled !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Cursor = Cursors.Default; return; } if (MachineLearning.Classes.IsContainNegative() || (MachineLearning.Classes.Count == 0)) { MessageBox.Show("Negative or null cluster index identified. Operation cancelled !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Cursor = Cursors.Default; return; } // ----- update well classes ------ int IdxWell = 0; foreach (cWell item in itemPlate.ListActiveWells) item.SetClass((int)MachineLearning.Classes[IdxWell++]); } } else { cListWells ListWell = new cListWells(null); foreach (cPlate itemPlate in ListPlatesToProcess) { foreach (cWell item in itemPlate.ListActiveWells) { //cExtendedList ListValues = item.GetAverageValuesList(false); //dt.Rows.Add(); //int RealIdx = 0; //for (int IdxDesc = 0; IdxDesc < CompleteScreening.ListDescriptors.Count; IdxDesc++) //{ // if (CompleteScreening.ListDescriptors[IdxDesc].IsActive()) // dt.Rows[dt.Rows.Count - 1][RealIdx++] = ListValues[IdxDesc]; ListWell.Add(item); //} } } dt = ListWell.GetAverageDescriptorValues(cGlobalInfo.CurrentScreening.ListDescriptors.GetActiveDescriptors(), false, false); MachineLearning.SelectedClusterer = MachineLearning.BuildClusterer(ParamAlgoForClustering, dt); if (MachineLearning.SelectedClusterer != null) { double[] Assign = MachineLearning.EvaluteAndDisplayClusterer(richTextBoxInfoClustering, null, MachineLearning.CreateInstancesWithoutClass(dt)).getClusterAssignments(); MachineLearning.Classes = new cExtendedList(); MachineLearning.Classes.AddRange(Assign); } if (MachineLearning.Classes.Max() >= cGlobalInfo.ListWellClasses.Count) { MessageBox.Show("The number of cluster is higher than the supported number of classes. Operation cancelled !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Cursor = Cursors.Default; return; } if (MachineLearning.Classes.IsContainNegative() || (MachineLearning.Classes.Count == 0)) { MessageBox.Show("Negative or null cluster index identified. Operation cancelled !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Cursor = Cursors.Default; return; } int IdxWell = 0; // ----- update well classes ------ foreach (cPlate itemPlate in ListPlatesToProcess) { foreach (cWell item in itemPlate.ListActiveWells) item.SetClass((int)MachineLearning.Classes[IdxWell++]); } } cGlobalInfo.CurrentScreening.GetCurrentDisplayPlate().DisplayDistribution(cGlobalInfo.CurrentScreening.ListDescriptors.GetActiveDescriptor(), false); this.Cursor = Cursors.Default; }
public cFeedBackMessage Run() { base.Start(); if (!FeedBackMessage.IsSucceed) return FeedBackMessage; if (this.Input.Count > 1) { this.FeedBackMessage = new cFeedBackMessage(false, this); return this.FeedBackMessage; } #region parameters initialization //object _firstValue = base.ListProperties.FindByName("Number of Clusters"); //int NumOfClusters = 0; //if (_firstValue == null) //{ // base.GenerateError("-Number of Clusters- not found !"); // return base.FeedBackMessage; //} //try //{ // cProperty TmpProp = (cProperty)_firstValue; // NumOfClusters = (int)TmpProp.GetValue(); //} //catch (Exception) //{ // base.GenerateError("-Number of Clusters- cast didn't work"); // return base.FeedBackMessage; //} #endregion cMachineLearning MachineLearning = new cMachineLearning(/*cWell.GlobalInfo*/null); if (ParamAlgoForClustering == null) ParamAlgoForClustering = MachineLearning.AskAndGetClusteringAlgo(); if (ParamAlgoForClustering == null) { FeedBackMessage.IsSucceed = false; FeedBackMessage.Message = "Invalid Parameters"; return FeedBackMessage; } MachineLearning.SelectedClusterer = MachineLearning.BuildClusterer(ParamAlgoForClustering, this.Input); if (MachineLearning.SelectedClusterer != null) { cLinearize L = new cLinearize(); L.SetInputData(this.Input); L.Run(); cExtendedTable Test = L.GetOutPut(); ClusterEvaluation CE = MachineLearning.EvaluteAndDisplayClusterer(/*richTextBoxInfoClustering*/null, null, MachineLearning.CreateInstancesWithoutClass(this.Input)); double[] Assign = CE.getClusterAssignments(); base.Output = new cExtendedTable(this.Input); cExtendedList CL = new cExtendedList("Class ID"); CL.SetInfo(CE.clusterResultsToString()); base.Output.Add(CL); for (int i = 0; i < Assign.Length; i++) base.Output[base.Output.Count-1].Add(Assign[i]); } base.End(); return FeedBackMessage; }
public cFeedBackMessage Run(bool IsDisplayResults) { cMachineLearning MachineLearning = new cMachineLearning(/*cWell.GlobalInfo*/null); ParamAlgoForClustering = MachineLearning.AskAndGetClusteringAlgo(); if (MinObjectsNumber == -1) MinObjectsNumber = (cGlobalInfo.CurrentScreening.Columns * cGlobalInfo.CurrentScreening.Rows * (int)cGlobalInfo.OptionsWindow.numericUpDownSystemMinWellRatio.Value) / 100; foreach (cPlate CurrentPlate in PlatesToProcess) { cExtendedTable CurrentPlateResult = null; foreach (var item in this.DescriptorsToProcess) { cExtendedTable ET = CurrentPlate.GetAverageValueList(item, false); ET.Name = item.GetName(); cExtendedTable ResultTable = this.GenerateArtifactMessage(ET, CurrentPlate); ResultTable.ListRowNames = new List<string>(); ResultTable.ListRowNames.Add(item.GetName()); if (CurrentPlateResult == null) CurrentPlateResult = new cExtendedTable(ResultTable); else { cMerge M = new cMerge(); M.IsHorizontal = false; M.SetInputData(CurrentPlateResult, ResultTable); M.Run(); CurrentPlateResult = M.GetOutPut(); } } CurrentPlateResult.Name = CurrentPlate.GetName(); CurrentPlateResult.Tag = CurrentPlate; this.Output.Add(CurrentPlateResult); } this.Output.Name = "Systematic Errors (" + PlatesToProcess.Count + " plate(s))"; if (IsDisplayResults) { cDisplayToWindow DTW = new cDisplayToWindow(); cDesignerMultiChoices DMC = new cDesignerMultiChoices(); foreach (var item in this.Output) { cDesignerSplitter DS = new cDesignerSplitter(); DS.Orientation = System.Windows.Forms.Orientation.Horizontal; DS.Title = item.Name; cViewerTable VT = new cViewerTable(); VT.SetInputData(item); VT.DigitNumber = 0; VT.Run(); DS.SetInputData(VT.GetOutPut()); cViewerHeatMap VHM = new cViewerHeatMap(); VHM.SetInputData(item); VHM.IsAutomatedMinMax = false; VHM.Min = 0; VHM.Max = 1; VHM.Run(); DS.SetInputData(VHM.GetOutPut()); DS.Run(); cExtendedControl TmpXCtrl = DS.GetOutPut(); TmpXCtrl.Tag = item.Tag; DMC.SetInputData(TmpXCtrl); } DMC.Run(); DTW.SetInputData(DMC.GetOutPut()); DTW.Title = "Systematic Errors [" + PlatesToProcess.Count + " plate(s)]"; DTW.Run(); DTW.Display(); //cDisplayListExtendedTable DLET = new cDisplayListExtendedTable(); //DLET.SetInputData(this.Output); //return DLET.Run(); } return FeedBackMessage; }
private void buttonNewClassificationProcess_Click(object sender, EventArgs e) { cMachineLearning MachineLearningForClassif = new cMachineLearning(this.GlobalInfo); //cParamAlgo AlgoAndParameters = MachineLearningForClassif.AskAndGetClassifAlgo(); // List<bool> ListClassSelected = ((PanelForClassSelection)panelForClassSelectionClustering.Controls[0]).GetListSelectedClass(); // cInfoClass InfoClass = new cInfoClass(); //Instances ListInstances = CompleteScreening.GetCurrentDisplayPlate().CreateInstancesWithClasses(ListClassSelected); cInfoClass InfoClass = cGlobalInfo.CurrentScreening.GetCurrentDisplayPlate().GetNumberOfClassesBut(comboBoxNeutralClassForClassif.SelectedIndex); Instances ListInstances = cGlobalInfo.CurrentScreening.GetCurrentDisplayPlate().CreateInstancesWithClasses(InfoClass, comboBoxNeutralClassForClassif.SelectedIndex); //panelForClassSelectionClustering weka.classifiers.Evaluation EvalClassif = new weka.classifiers.Evaluation(ListInstances); MachineLearningForClassif.PerformTraining(MachineLearningForClassif.AskAndGetClassifAlgo(), ListInstances, //InfoClass.NumberOfClass, richTextBoxInfoClustering, panelTMPForFeedBack, out EvalClassif, false); }
public FormForSingleCellsDisplay(cExtendedTable InputTable, cExtendedList ListClasses) { InitializeComponent(); SliderForOpacity.numericUpDown.Maximum = 255; SliderForOpacity.numericUpDown.Value = this.Opacity; this.InputTable = InputTable; // build the panel for the phenotypic selection PanelPhenotypeSelection = new PanelForClassSelection(true, eClassType.PHENOTYPE); PanelPhenotypeSelection.SelectionChanged += new PanelForClassSelection.ChangedEventHandler(PanelPhenotypeSelection_SelectionChanged); PanelPhenotypeSelection.Height = this.panelForClasses.Height; this.panelForClasses.Controls.Add(PanelPhenotypeSelection); #region initialize histograms display splitContainerHorizontal.Panel1Collapsed = true; splitContainerVertical.Panel2Collapsed = true; System.Drawing.Image ImageOriginal = (System.Drawing.Image)(Properties.Resources.Arrow); if (splitContainerVertical.Panel2Collapsed) ImageOriginal.RotateFlip(RotateFlipType.Rotate270FlipNone); else ImageOriginal.RotateFlip(RotateFlipType.Rotate90FlipNone); buttonCollapseVertical.BackgroundImage = ImageOriginal; #endregion MachineLearning = new cMachineLearning(GlobalInfo); MachineLearning.Classes.AddRange(ListClasses); WindowForModelHistory.Show(); WindowForModelHistory.Visible = false; ToolTipForX.AutoPopDelay = ToolTipForY.AutoPopDelay = 5000; ToolTipForX.InitialDelay = ToolTipForY.InitialDelay = 500; ToolTipForX.ReshowDelay = ToolTipForY.ReshowDelay = 500; ToolTipForX.ShowAlways = ToolTipForY.ShowAlways = true; ToolTipForX.SetToolTip(comboBoxAxeX, comboBoxAxeX.Text); ToolTipForY.SetToolTip(comboBoxAxeY, comboBoxAxeY.Text); ToolTipForVolume.SetToolTip(comboBoxVolume, comboBoxVolume.Text); this.chartForPoints.ChartAreas[0].CursorX.Interval = double.Epsilon; this.chartForPoints.ChartAreas[0].CursorY.Interval = double.Epsilon; this.chartForPoints.MouseClick += new System.Windows.Forms.MouseEventHandler(this.AssociatedChart_MouseClick); for (int i = 0; i < cGlobalInfo.ListCellularPhenotypes.Count; i++) { this.ListPhenotypeVisible.Add(true); } }