Example #1
0
        public async Task <string> GetBody(EM em, IEnumerable <FirmeDto> firme)
        {
            try
            {
                var atto = await _unitOfWork.Atti.Get(em.UIDAtto);

                var personeInDb = await _unitOfWork.Persone.GetAll();

                var personeInDbLight = personeInDb.Select(Mapper.Map <View_UTENTI, PersonaLightDto>).ToList();

                var persona        = personeInDb.First(p => p.UID_persona == em.UIDPersonaProponente);
                var personaDto     = Mapper.Map <View_UTENTI, PersonaDto>(persona);
                var emendamentoDto = await _logicEm.GetEM_DTO(em, atto, personaDto, personeInDbLight);

                var attoDto = Mapper.Map <ATTI, AttiDto>(atto);

                try
                {
                    var body = GetTemplate(TemplateTypeEnum.PDF);
                    GetBody(emendamentoDto, attoDto, firme, personaDto, false, ref body);
                    return(body);
                }
                catch (Exception e)
                {
                    Log.Error("GetBodyEM", e);
                    throw e;
                }
            }
            catch (Exception e)
            {
                Log.Error("Logic - GetBodyEM", e);
                throw e;
            }
        }
Example #2
0
        public void TestEM2()
        {
            Random r = new Random(DateTime.Now.Millisecond);
            int    numberOfPoints   = 2000;
            int    dimensions       = 20;
            int    numberOfClusters = 10;

            //using (
            //   EM.Params p = new EM.Params(numberOfClusters, MlEnum.EmCovarianMatrixType.Diagonal,
            //      new MCvTermCriteria(100, 1.0e-6)))
            using (EM em = new EM())
            {
                em.ClustersNumber       = numberOfClusters;
                em.CovarianceMatrixType = EM.CovarianMatrixType.Diagonal;
                em.TermCriteria         = new MCvTermCriteria(100, 1.0e-6);
                //ParamDef[] parameters = em.GetParams();
                Matrix <int>   labels    = new Matrix <int>(numberOfPoints, 1);
                Matrix <float> featuresM = new Matrix <float>(numberOfPoints, dimensions);
                for (int i = 0; i < numberOfPoints; i++)
                {
                    for (int j = 0; j < dimensions; j++)
                    {
                        featuresM[i, j] = 100 * (float)r.NextDouble() - 50;
                    }
                }

                em.Train(featuresM, MlEnum.DataLayoutType.RowSample, labels);
            }
        }
Example #3
0
        public void TestEMCreate()
        {
            using var em = EM.Create();
            var name = em.GetDefaultName();

            Assert.Equal("opencv_ml_em", name);
        }
Example #4
0
        public void TestEM2()
        {
            Random r = new Random(DateTime.Now.Millisecond);
            int    N = 2000;
            int    D = 20;
            int    G = 10;

            EM             Em        = new EM();
            Matrix <int>   labels    = new Matrix <int>(N, 1);
            Matrix <float> featuresM = new Matrix <float>(N, D);

            for (int i = 0; i < N; i++)
            {
                for (int j = 0; j < D; j++)
                {
                    featuresM[i, j] = 100 * (float)r.NextDouble() - 50;
                }
            }

            EMParams pars = new EMParams();

            pars.CovMatType = Emgu.CV.ML.MlEnum.EM_COVARIAN_MATRIX_TYPE.COV_MAT_DIAGONAL;
            pars.Nclusters  = G;
            pars.StartStep  = Emgu.CV.ML.MlEnum.EM_INIT_STEP_TYPE.START_AUTO_STEP;
            pars.TermCrit   = new MCvTermCriteria(100, 1.0e-6);

            Em.Train(featuresM, null, pars, labels);
        }
Example #5
0
        /// <summary>
        /// perform an EM clustering over the entire screening data
        /// </summary>
        /// <param name="ClassNumber"></param>
        private string ClusteringEMGlobalScreen(int ClassNumber, FormForEMInfo WindowEMinfo)
        {
            weka.core.Instances Ninsts = cGlobalInfo.CurrentScreening.CreateInstancesWithoutClass();// CreateInstanceWithoutClass(CurrentTable);

            weka.clusterers.EM EMCluster = new EM();
            EMCluster.setNumClusters(ClassNumber);
            EMCluster.setMaxIterations((int)WindowEMinfo.numericUpDownMaxIterations.Value);
            EMCluster.setMinStdDev((double)WindowEMinfo.numericUpDownMinStdev.Value);
            EMCluster.setSeed((int)WindowEMinfo.numericUpDownSeedNumber.Value);

            EMCluster.buildClusterer(Ninsts);
            EMCluster.getClusterModelsNumericAtts();
            if (EMCluster.numberOfClusters() > cGlobalInfo.ListWellClasses.Count)
            {
                richTextBoxInfoClustering.AppendText("\nCluster Number: more than " + cGlobalInfo.ListWellClasses.Count + ", clustering not operated.\n");
                return null;
            }

            richTextBoxInfoClustering.AppendText("\n" + EMCluster.numberOfClusters() + " cluster(s) identified");

            ClusterEvaluation eval = new ClusterEvaluation();
            eval.setClusterer(EMCluster);
            eval.evaluateClusterer(Ninsts);

            cGlobalInfo.CurrentScreening.AssignClass(eval.getClusterAssignments());

            return eval.clusterResultsToString();
        }
Example #6
0
        public void TestLikelihood()
        {
            EM     em         = new EM(new double[0], 1);
            double likelihood = em.Likelihood(2, 0, 1);

            Console.WriteLine(likelihood);
        }
Example #7
0
        public async Task <IEnumerable <FIRME> > GetFirme(EM em, FirmeTipoEnum tipo)
        {
            try
            {
                var result = await _unitOfWork
                             .Firme
                             .GetFirmatari(em, tipo);

                var firme = result.ToList();

                if (!firme.Any())
                {
                    return(firme);
                }

                firme.ForEach(f => f.FirmaCert        = Decrypt(f.FirmaCert));
                firme.ForEach(f => f.Data_firma       = Decrypt(f.Data_firma));
                firme.ForEach(f => f.Data_ritirofirma = string.IsNullOrEmpty(f.Data_ritirofirma)
                    ? null
                    : Decrypt(f.Data_ritirofirma));

                return(result);
            }
            catch (Exception e)
            {
                Log.Error("Logic - GetFirme", e);
                throw e;
            }
        }
Example #8
0
        public void TestEMCreate()
        {
            var em   = EM.Create();
            var name = em.GetDefaultName();

            Assert.Equal(name, "opencv_ml_em");
        }
Example #9
0
                internal static void Main()
                {
                    var em = new EM();
                    var proc = new Niki(em);

                    while (true)
                    {
                        string ct = Console.ReadLine();
                        if (ct == "End" || ct == null)
                        {
                            goto end;
                        }

                        try
                        {
                            // The sequence of commands is finished
                            Console.WriteLine(proc.ProcessCommand(Command.Parse(ct)));
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message);
                        }
                    }

                    end:
                    {
                    }
                }
Example #10
0
        public void TestEMRun()
        {
            EM em = new EM(new double[5] {
                -2, -1, 0, 1, 2
            }, 2);

            em.Run();
        }
Example #11
0
        public void TestEStep()
        {
            EM em = new EM(new double[5] {
                -2, -1, 0, 1, 2
            }, 3);

            em.E();
        }
        private void DoIndependentMod(byte[] binary)
        {
            IIndependentModifier m = Serialisation.To <IIndependentModifier>(binary);

            PingSimulator.Delay(() => {
                EM.ApplyMod(m, DistributeBetweenPlayersAsyncFilter);
            });
        }
Example #13
0
 /// <summary>
 /// pushes a contact onto the end of the list since that is where all new contacts will be added.
 /// </summary>
 public void AddContact()
 {
     Thermal.Add(0);
     ThermalYear.Add(0);
     EM.Add(0);
     EMYear.Add(0);
     Active.Add(0);
     ActiveYear.Add(0);
 }
Example #14
0
 /// <summary>
 /// Removes a contact at the specified index.
 /// </summary>
 /// <param name="RemIndex">index to be removed.</param>
 public void RemoveContact(int RemIndex)
 {
     Thermal.RemoveAt(RemIndex);
     ThermalYear.RemoveAt(RemIndex);
     EM.RemoveAt(RemIndex);
     EMYear.RemoveAt(RemIndex);
     Active.RemoveAt(RemIndex);
     ActiveYear.RemoveAt(RemIndex);
 }
Example #15
0
 public void UpdateSettingsView()
 {
     TextBox_StartingEnergy.Text = Starting_Energy.ToString();
     TextBox_Quanta.Text         = Quanta.ToString();
     TextBox_SHr.Text            = SH.ToString().PadLeft(2, '0');
     TextBox_SMin.Text           = SM.ToString().PadLeft(2, '0');
     TextBox_EHr.Text            = EH.ToString().PadLeft(2, '0');
     TextBox_EMin.Text           = EM.ToString().PadLeft(2, '0');
 }
Example #16
0
 public void InitAll(SRMData data, EMConf emconf, IMessage msg)
 {
     foreach (HErlangEMSRM model in allmodels)
     {
         EM em = new EM(model, emconf, msg);
         em.Initialize(data);
         maxmodel = model;
     }
 }
Example #17
0
        public void TestExpectedzij()
        {
            EM em = new EM(new double[5] {
                -2, -1, 0, 1, 2
            }, 2);
            double expected = em.Expected_zij(0, 1);

            Assert.AreEqual(0.5, expected, "0 falls in the middle and should be 0.5");
            Console.WriteLine(expected);
        }
Example #18
0
 bool ApplyEffects()
 {
     foreach (var player in PlayerList)
     {
         while (player.HasEffect && EM.Apply(player))
         {
             ;
         }
     }
     return(!PlayerList.Where(pl => pl.HasEffect).Any()); // false - эффекты не погашены
 }
Example #19
0
 internal static string GetNomeEM(EM emendamento, EM riferimento)
 {
     try
     {
         return(GetNomeEM(Mapper.Map <EM, EmendamentiDto>(emendamento),
                          Mapper.Map <EM, EmendamentiDto>(riferimento)));
     }
     catch (Exception e)
     {
         Log.Error("GetNomeEM", e);
         throw e;
     }
 }
        private void DoIndependentModWithConfirmation(object[] args)
        {
            int sourcePlayerID;
            IIndependentModifier m;
            int  requestID;
            long targetStep;

            Serialisation.ToObjects(args, out sourcePlayerID, out m, out requestID, out targetStep);

            PingSimulator.Delay(() => {
                EM.ApplyMod(m, DistributeBetweenPlayersAsyncFilter);
                View.RPC("ConfirmModExecuted", PhotonNetwork.playerList[sourcePlayerID - 1], PhotonNetwork.player.ID, requestID);
            });
        }
        /// <summary>
        ///     Riepilogo firmatari
        /// </summary>
        /// <param name="emendamentoUId"></param>
        /// <returns></returns>
        public async Task <IEnumerable <FIRME> > GetFirmatari(EM em, FirmeTipoEnum tipo)
        {
            var firmaProponente = await PRContext
                                  .FIRME
                                  .SingleOrDefaultAsync(f =>
                                                        f.UIDEM == em.UIDEM &&
                                                        f.UID_persona == em.UIDPersonaProponente);

            var query = PRContext
                        .FIRME
                        .Where(f => f.UIDEM == em.UIDEM &&
                               f.UID_persona != em.UIDPersonaProponente);

            switch (tipo)
            {
            case FirmeTipoEnum.TUTTE:
                break;

            case FirmeTipoEnum.PRIMA_DEPOSITO:
                if (em.IDStato >= (int)StatiEnum.Depositato)
                {
                    query = query.Where(f => f.Timestamp < em.Timestamp);
                }

                break;

            case FirmeTipoEnum.DOPO_DEPOSITO:
                query = query.Where(f => f.Timestamp > em.Timestamp);
                break;

            case FirmeTipoEnum.ATTIVI:
                query = query.Where(f => string.IsNullOrEmpty(f.Data_ritirofirma));
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(tipo), tipo, null);
            }

            query = query.OrderBy(f => f.Timestamp);

            var lst = await query
                      .ToListAsync();

            if (firmaProponente != null && tipo != FirmeTipoEnum.DOPO_DEPOSITO)
            {
                lst.Insert(0, firmaProponente);
            }

            return(lst);
        }
Example #22
0
        public async Task SetPHRole(SocketRole PH = default)
        {
            EM.SetPlaceHolderRole(PH);

            if (PH == default)
            {
                _ = ReplyAsync($":white_check_mark: | Cleared PlaceHolder role!");
            }

            else
            {
                _ = ReplyAsync($":white_check_mark: | {PH.Mention} is now the PlaceHolder role!");
            }
        }
        private void DoEntityDependentMod(object[] args)
        {
            IEntity         e;
            IEntityModifier m;

            Serialisation.ToObjects(args, out e, out m);

            PingSimulator.Delay(() => {
                m.e = e;
                EM.RefreshEntityOnModifierUsingUID(m);

                EM.ApplyMod(m, DistributeBetweenPlayersAsyncFilter);
            });
        }
Example #24
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            switch (cb_tipoUtilizador.Text)
            {
            case "Aluno":
                foreach (Aluno A in RD.GetListaPessoa().OfType <Aluno>())
                {
                    if (A.GetUser() == txt_username.Text && A.GetPass() == txt_Password.Text)
                    {
                        RD.SetLogin(A.GetNome());
                        this.DialogResult = DialogResult.Yes;
                    }
                }
                break;

            case "Docente":
                foreach (Docente D in RD.GetListaPessoa().OfType <Docente>())
                {
                    if (D.GetUser() == txt_username.Text && D.GetPass() == txt_Password.Text)
                    {
                        RD.SetLogin(D.GetNome());
                        this.DialogResult = DialogResult.Yes;
                    }
                }
                break;

            case "Orientador":
                foreach (OrientadorEmpresa OE in RD.GetListaPessoa().OfType <OrientadorEmpresa>())
                {
                    if (OE.GetUser() == txt_username.Text && OE.GetPass() == txt_Password.Text)
                    {
                        RD.SetLogin(OE.GetNome());
                        this.DialogResult = DialogResult.Yes;
                    }
                }
                break;

            case "Empresa":
                foreach (Empresa EM in RD.GetListaEmpresa())
                {
                    if (EM.GetUser() == txt_username.Text && EM.GetPass() == txt_Password.Text)
                    {
                        RD.SetLogin(EM.GetNome());
                        this.DialogResult = DialogResult.Yes;
                    }
                }
                break;
            }
        }
Example #25
0
 public void FitAll(SRMData data, EMConf emconf, IMessage msg)
 {
     maxllf = double.MinValue;
     foreach (HErlangEMSRM model in allmodels)
     {
         EM em = new EM(model, emconf, msg);
         em.Fit(data);
         if (emconf.Llf > maxllf)
         {
             maxllf   = emconf.Llf;
             maxmodel = model;
             maxconf.Set(emconf);
         }
     }
     emconf.Set(maxconf);
 }
        private void DoEntityDependentModWithConfirmation(object[] args)
        {
            int             sourcePlayerID;
            IEntityModifier m;
            int             requestID;
            long            targetStep;

            Serialisation.ToObjects(args, out sourcePlayerID, out m, out requestID, out targetStep);

            PingSimulator.Delay(() => {
                // If the modifier holds an entity value, retrieve it from its local registry using its UID
                EM.RefreshEntityOnModifierUsingUID(m);

                EM.ApplyMod(m, DistributeBetweenPlayersAsyncFilter);
                View.RPC("ConfirmModExecuted", PhotonNetwork.playerList[sourcePlayerID - 1], PhotonNetwork.player.ID, requestID);
            });
        }
Example #27
0
        public void DestroyedSphere_IncreasesScoreByOne()
        {
            var gameStateEntity = EM.CreateEntity();

            EM.AddComponent <GameState>(gameStateEntity);

            var destroyedSphere = EM.CreateEntity();

            EM.AddComponent <DestroyedTag>(destroyedSphere);
            EM.AddComponent <SphereTag>(destroyedSphere);

            W.Update();

            var GameState = EM.GetComponentData <GameState>(gameStateEntity);

            Assert.AreEqual(1, GameState.score);
        }
Example #28
0
        private void Prefs_OK_Click(object sender, RoutedEventArgs e)
        {
            foreach (EVEData.System s in EM.Systems)
            {
                s.HasJumpBeacon = false;
            }

            foreach (string sys in CynoBeaconSystems)
            {
                EVEData.System es = EM.GetEveSystem(sys);
                if (es != null)
                {
                    es.HasJumpBeacon = true;
                }
            }

            Close();
        }
Example #29
0
    public static object Do(object Me, MethodBase M, List <object> O)
    {
        if ((!Description.SpecialVar) && (MList.L.Count > 0))
        {
            lock (MList.threadLock)
            {
                O = MList.L.Select(x => x);
                MList.L.Clear();
            }
        }
        var        e = Z.GetfromM(M);
        var        u = e.O.GetfromO(Me);
        MethodInfo BM, EM;

        if (u == null)
        {
            BM = e.BasicBeginM;
            EM = e.BasicEndM;
        }
        else
        {
            BM = u.BeginM;
            EM = u.EndM;
        }
        if (BM != null)
        {
            BM.Invoke(null, new object[] { Me, M, O });
        }

        byte[] R = e.BegCode;
        e.HandlersConditionsInst.ForEach(x => R = AOP.Handlers[x](R, Me, e, O));
        InjectionHelper.UpdateILCodes(M, R);
        object Res = M.Invoke(Me, O.ToArray());

        // InjectionHelper.UpdateILCodes(M, this.GetType().GetMethod("ORunner_" + O.Count.ToString()).GetMethodBody().GetILAsByteArray());
        InjectionHelper.UpdateILCodes(M, e.ChangeCode);
        if (EM != null)
        {
            EM.Invoke(null, new object[] { Res, Me, M, O });
        }
        return(Res);
    }
        public async Task <IEnumerable <FirmeDto> > GetFirme(EM em, FirmeTipoEnum tipo)
        {
            try
            {
                var firmeInDb = await _unitOfWork
                                .Firme
                                .GetFirmatari(em, tipo);

                var firme = firmeInDb.ToList();

                if (!firme.Any())
                {
                    return(new List <FirmeDto>());
                }

                var result = new List <FirmeDto>();
                foreach (var firma in firme)
                {
                    var firmaDto = new FirmeDto
                    {
                        UIDEM            = firma.UIDEM,
                        UID_persona      = firma.UID_persona,
                        FirmaCert        = Decrypt(firma.FirmaCert),
                        Data_firma       = Decrypt(firma.Data_firma),
                        Data_ritirofirma = string.IsNullOrEmpty(firma.Data_ritirofirma)
                        ? null
                        : Decrypt(firma.Data_ritirofirma)
                    };

                    result.Add(firmaDto);
                }

                return(result);
            }
            catch (Exception e)
            {
                Log.Error("Logic - GetFirme", e);
                throw e;
            }
        }
Example #31
0
 private bool UpdateSettings()
 {
     try
     {
         Starting_Energy = Convert.ToInt32(TextBox_StartingEnergy.Text);
         Quanta          = Convert.ToInt32(TextBox_Quanta.Text);
         SH   = Convert.ToInt32(TextBox_SHr.Text);
         SM   = Convert.ToInt32(TextBox_SMin.Text);
         EH   = Convert.ToInt32(TextBox_EHr.Text);
         EM   = Convert.ToInt32(TextBox_EMin.Text);
         SMer = Combo_S.SelectedValue.ToString();
         EMer = Combo_E.SelectedValue.ToString();
         RectifyTime();
         STime = SH.ToString().PadLeft(2, '0') + ":" + SM.ToString().PadLeft(2, '0') + SMer;
         ETime = EH.ToString().PadLeft(2, '0') + ":" + EM.ToString().PadLeft(2, '0') + EMer;
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Example #32
0
        /// <summary>
        /// perform an EM clustering over the entire screening data
        /// </summary>
        /// <param name="ClassNumber"></param>
        private void ClusteringEMGlobalScreen(int ClassNumber)
        {
            weka.core.Instances Ninsts = CompleteScreening.CreateInstancesWithoutClass();// CreateInstanceWithoutClass(CurrentTable);

            weka.clusterers.EM EMCluster = new EM();
            EMCluster.setNumClusters(ClassNumber);
            EMCluster.buildClusterer(Ninsts);
            EMCluster.getClusterModelsNumericAtts();
            if (EMCluster.numberOfClusters() > GlobalInfo.GetNumberofDefinedClass())
            {
                richTextBoxInfoClustering.AppendText("\nCluster Number: more than " + GlobalInfo.GetNumberofDefinedClass() + ", clustering not operated.\n");
                return;
            }
            else
                richTextBoxInfoClustering.AppendText("\n" + EMCluster.numberOfClusters() + " cluster(s) identified");

            ClusterEvaluation eval = new ClusterEvaluation();
            eval.setClusterer(EMCluster);
            eval.evaluateClusterer(Ninsts);

            CompleteScreening.AssignClass(eval.getClusterAssignments());
        }
Example #33
0
        /// <summary>
        /// Perform an EM clustering on each plate independantely
        /// </summary>
        /// <param name="CurrentPlateToProcess">the plate to process</param>
        /// <param name="ClassNumber">Number of class</param>
        private void ClusteringEMSinglePlate(cPlate CurrentPlateToProcess, int ClassNumber, FormForEMInfo WindowEMinfo)
        {
            weka.core.Instances Ninsts = CurrentPlateToProcess.CreateInstancesWithoutClass();// CreateInstanceWithoutClass(CurrentTable);
            if (Ninsts.numInstances() == 0)
            {
                MessageBox.Show("No active wells !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            weka.clusterers.EM EMCluster = new EM();
            EMCluster.setNumClusters(ClassNumber);

            EMCluster.setMaxIterations((int)WindowEMinfo.numericUpDownMaxIterations.Value);
            EMCluster.setMinStdDev((double)WindowEMinfo.numericUpDownMinStdev.Value);
            EMCluster.setSeed((int)WindowEMinfo.numericUpDownSeedNumber.Value);

            EMCluster.buildClusterer(Ninsts);
            EMCluster.getClusterModelsNumericAtts();
            if (EMCluster.numberOfClusters() > GlobalInfo.GetNumberofDefinedClass())
            {
                richTextBoxInfoClustering.AppendText("\n Plate " + CurrentPlateToProcess.Name + ", cluster Number: more than " + GlobalInfo.GetNumberofDefinedClass() + ", clustering not operated.\n");
                return;
            }
            else
                richTextBoxInfoClustering.AppendText("\n" + CurrentPlateToProcess.Name + ": " + EMCluster.numberOfClusters() + " cluster(s)");

            ClusterEvaluation eval = new ClusterEvaluation();
            eval.setClusterer(EMCluster);
            eval.evaluateClusterer(Ninsts);

            CurrentPlateToProcess.AssignClass(eval.getClusterAssignments());
        }
Example #34
0
        public void TestEM2()
        {
            Random r = new Random(DateTime.Now.Millisecond);
             int N = 2000;
             int D = 20;
             int G = 10;

             EM Em = new EM();
             Matrix<int> labels = new Matrix<int>(N, 1);
             Matrix<float> featuresM = new Matrix<float>(N, D);
             for (int i = 0; i < N; i++)
            for (int j = 0; j < D; j++)
               featuresM[i, j] = 100 * (float)r.NextDouble() - 50;

             EMParams pars = new EMParams();
             pars.CovMatType = Emgu.CV.ML.MlEnum.EM_COVARIAN_MATRIX_TYPE.COV_MAT_DIAGONAL;
             pars.Nclusters = G;
             pars.StartStep = Emgu.CV.ML.MlEnum.EM_INIT_STEP_TYPE.START_AUTO_STEP;
             pars.TermCrit = new MCvTermCriteria(100, 1.0e-6);

             Em.Train(featuresM, null, pars, labels);
        }
Example #35
0
        public void TestEM()
        {
            int N = 4; //number of clusters
             int N1 = (int)Math.Sqrt((double)4);

             Bgr[] colors = new Bgr[] {
            new Bgr(0, 0, 255),
            new Bgr(0, 255, 0),
            new Bgr(0, 255, 255),
            new Bgr(255, 255, 0)};

             int nSamples = 100;

             Matrix<float> samples = new Matrix<float>(nSamples, 2);
             Matrix<Int32> labels = new Matrix<int>(nSamples, 1);
             Image<Bgr, Byte> img = new Image<Bgr,byte>(500, 500);
             Matrix<float> sample = new Matrix<float>(1, 2);

             CvInvoke.cvReshape(samples.Ptr, samples.Ptr, 2, 0);
             for (int i = 0; i < N; i++)
             {
            Matrix<float> rows = samples.GetRows(i * nSamples / N, (i + 1) * nSamples / N, 1);
            double scale = ((i % N1) + 1.0) / (N1 + 1);
            MCvScalar mean = new MCvScalar(scale * img.Width, scale * img.Height);
            MCvScalar sigma = new MCvScalar(30, 30);
            rows.SetRandNormal(mean, sigma);
             }
             CvInvoke.cvReshape(samples.Ptr, samples.Ptr, 1, 0);

             using (EM emModel1 = new EM())
             using (EM emModel2 = new EM())
             {
            EMParams parameters1 = new EMParams();
            parameters1.Nclusters = N;
            parameters1.CovMatType = Emgu.CV.ML.MlEnum.EM_COVARIAN_MATRIX_TYPE.COV_MAT_DIAGONAL;
            parameters1.StartStep = Emgu.CV.ML.MlEnum.EM_INIT_STEP_TYPE.START_AUTO_STEP;
            parameters1.TermCrit = new MCvTermCriteria(10, 0.01);
            emModel1.Train(samples, null, parameters1, labels);

            EMParams parameters2 = new EMParams();
            parameters2.Nclusters = N;
            parameters2.CovMatType = Emgu.CV.ML.MlEnum.EM_COVARIAN_MATRIX_TYPE.COV_MAT_GENERIC;
            parameters2.StartStep = Emgu.CV.ML.MlEnum.EM_INIT_STEP_TYPE.START_E_STEP;
            parameters2.TermCrit = new MCvTermCriteria(100, 1.0e-6);
            parameters2.Means = emModel1.Means;
            parameters2.Covs = emModel1.GetCovariances();
            parameters2.Weights = emModel1.Weights;

            emModel2.Train(samples, null, parameters2, labels);

            //TODO: Find out when saving of EM model will be enable
            //emModel2.Save("emModel.xml");

            #region Classify every image pixel
            for (int i = 0; i < img.Height; i++)
               for (int j = 0; j < img.Width; j++)
               {
                  sample.Data[0, 0] = i;
                  sample.Data[0, 1] = j;
                  int response = (int) emModel2.Predict(sample, null);

                  Bgr color = colors[response];

                  img[j, i] = new Bgr(color.Blue*0.5, color.Green * 0.5, color.Red * 0.5 );
               }
            #endregion

            #region draw the clustered samples
            for (int i = 0; i < nSamples; i++)
            {
               img.Draw(new CircleF(new PointF(samples.Data[i, 0], samples.Data[i, 1]), 1), colors[labels.Data[i, 0]], 0);
            }
            #endregion
             }
        }
Example #36
0
        /// <summary>
        /// Perform an EM clustering on each plate independantely
        /// </summary>
        /// <param name="CurrentPlateToProcess">the plate to process</param>
        /// <param name="ClassNumber">Number of class</param>
        private void ClusteringEMSinglePlate(cPlate CurrentPlateToProcess, int ClassNumber, FormForEMInfo WindowEMinfo)
        {
            weka.core.Instances Ninsts = CurrentPlateToProcess.CreateInstancesWithoutClass();// CreateInstanceWithoutClass(CurrentTable);

            weka.clusterers.EM EMCluster = new EM();
            EMCluster.setNumClusters(ClassNumber);

            EMCluster.setMaxIterations((int)WindowEMinfo.numericUpDownMaxIterations.Value);
            EMCluster.setMinStdDev((double)WindowEMinfo.numericUpDownMinStdev.Value);
            EMCluster.setSeed((int)WindowEMinfo.numericUpDownSeedNumber.Value);

            EMCluster.buildClusterer(Ninsts);
            EMCluster.getClusterModelsNumericAtts();
            if (EMCluster.numberOfClusters() > cGlobalInfo.ListWellClasses.Count)
            {
                richTextBoxInfoClustering.AppendText("\n Plate " + CurrentPlateToProcess.GetName() + ", cluster Number: more than " + cGlobalInfo.ListWellClasses.Count + ", clustering not operated.\n");
                return;
            }
            else
                richTextBoxInfoClustering.AppendText("\n" + CurrentPlateToProcess.GetName() + ": " + EMCluster.numberOfClusters() + " cluster(s)");

            ClusterEvaluation eval = new ClusterEvaluation();
            eval.setClusterer(EMCluster);
            eval.evaluateClusterer(Ninsts);

            CurrentPlateToProcess.AssignClass(eval.getClusterAssignments());
        }
Example #37
0
        /// <summary>
        /// display a GUI and generate the WEKA based clusterer
        /// </summary>
        /// <param name="InstancesList">list of the weka instance</param>
        /// <returns>weka clusterer</returns>
        public Clusterer BuildClusterer(cParamAlgo ClusteringAlgo, cExtendedTable Input)
        {
            this.InputTable = Input;

            foreach (var item in Input)
            {
                this.ListDescriptors.Add(item.Name);
            }

            cListValuesParam Parameters = ClusteringAlgo.GetListValuesParam();

            Clusterer ClustererToReturn = null;
            Instances ListInstancesWithoutClasses = CreateInstancesWithoutClass(Input);
            #region EM
            if (ClusteringAlgo.Name == "EM")
            {
                ClustererToReturn = new EM();

                if (Parameters.ListCheckValues.Get("checkBoxAutomatedClassNum").Value)
                    ((EM)ClustererToReturn).setNumClusters(-1);
                else
                    ((EM)ClustererToReturn).setNumClusters((int)Parameters.ListDoubleValues.Get("numericUpDownNumClasses").Value);

                ((EM)ClustererToReturn).setMaxIterations((int)Parameters.ListDoubleValues.Get("numericUpDownMaxIterations").Value);
                ((EM)ClustererToReturn).setMinStdDev((double)Parameters.ListDoubleValues.Get("numericUpDownMinStdev").Value);
                ((EM)ClustererToReturn).setSeed((int)Parameters.ListDoubleValues.Get("numericUpDownSeedNumber").Value);
                ClustererToReturn.buildClusterer(ListInstancesWithoutClasses);
                this.NumberOfClusters = ClustererToReturn.numberOfClusters();
            }
            #endregion
            #region K Means
            else if (ClusteringAlgo.Name == "K-Means")
            {
                ClustererToReturn = new SimpleKMeans();
                ((SimpleKMeans)ClustererToReturn).setNumClusters((int)Parameters.ListDoubleValues.Get("numericUpDownNumClasses").Value);
                ((SimpleKMeans)ClustererToReturn).setSeed((int)Parameters.ListDoubleValues.Get("numericUpDownSeedNumber").Value);

                string DistanceType = (string)Parameters.ListTextValues.Get("comboBoxDistance").Value;

                if (DistanceType == "Euclidean")
                {
                    EuclideanDistance ED = new EuclideanDistance();
                    ED.setDontNormalize(!(bool)Parameters.ListCheckValues.Get("checkBoxNormalize").Value);
                    ((SimpleKMeans)ClustererToReturn).setDistanceFunction(ED);
                }
                else if (DistanceType == "Manhattan")
                {
                    ManhattanDistance MD = new ManhattanDistance();
                    MD.setDontNormalize(!(bool)Parameters.ListCheckValues.Get("checkBoxNormalize").Value);
                    ((SimpleKMeans)ClustererToReturn).setDistanceFunction(MD);
                }
                else return null;
                ClustererToReturn.buildClusterer(ListInstancesWithoutClasses);
                this.NumberOfClusters = ClustererToReturn.numberOfClusters();
            }
            #endregion
            //#region K Means++
            //else if (ClusteringAlgo.Name == "K-Means++")
            //{
            //    ClustererToReturn = new SimpleKMeans();
            //    ((SimpleKMeans)ClustererToReturn).setNumClusters((int)Parameters.ListDoubleValues.Get("numericUpDownNumClasses").Value);
            //    ((SimpleKMeans)ClustererToReturn).setSeed((int)Parameters.ListDoubleValues.Get("numericUpDownSeedNumber").Value);

            //    string DistanceType = (string)Parameters.ListTextValues.Get("comboBoxDistance").Value;

            //    if (DistanceType == "Euclidean")
            //    {
            //        EuclideanDistance ED = new EuclideanDistance();
            //        ED.setDontNormalize(!(bool)Parameters.ListCheckValues.Get("checkBoxNormalize").Value);
            //        ((SimpleKMeans)ClustererToReturn).setDistanceFunction(ED);
            //    }
            //    else if (DistanceType == "Manhattan")
            //    {
            //        ManhattanDistance MD = new ManhattanDistance();
            //        MD.setDontNormalize(!(bool)Parameters.ListCheckValues.Get("checkBoxNormalize").Value);
            //        ((SimpleKMeans)ClustererToReturn).setDistanceFunction(MD);
            //    }
            //    else return null;
            //    ClustererToReturn.buildClusterer(ListInstancesWithoutClasses);
            //    this.NumberOfClusters = ClustererToReturn.numberOfClusters();
            //}
            //#endregion

            #region hierarchical
            else if (ClusteringAlgo.Name == "Hierarchical")
            {
                ClustererToReturn = new weka.clusterers.HierarchicalClusterer();
                string OptionDistance = " -N " + (int)Parameters.ListDoubleValues.Get("numericUpDownNumClasses").Value;

                string DistanceType = (string)Parameters.ListTextValues.Get("comboBoxDistance").Value;
                OptionDistance += " -A \"weka.core.";
                switch (DistanceType)
                {
                    case "Euclidean":
                        OptionDistance += "EuclideanDistance";
                        break;
                    case "Manhattan":
                        OptionDistance += "ManhattanDistance";
                        break;
                    case "Chebyshev":
                        OptionDistance += "ChebyshevDistance";
                        break;
                    default:
                        break;
                }

                if (!(bool)Parameters.ListCheckValues.Get("checkBoxNormalize").Value)
                    OptionDistance += " -D";
                OptionDistance += " -R ";

                OptionDistance += "first-last\"";
                string WekaOption = "-L " + (string)Parameters.ListTextValues.Get("comboBoxLinkType").Value + OptionDistance;
                ((HierarchicalClusterer)ClustererToReturn).setOptions(weka.core.Utils.splitOptions(WekaOption));

                ClustererToReturn.buildClusterer(ListInstancesWithoutClasses);
                this.NumberOfClusters = ClustererToReturn.numberOfClusters();
            }
            #endregion
            #region Farthest First
            else if (ClusteringAlgo.Name == "FarthestFirst")
            {
                ClustererToReturn = new weka.clusterers.FarthestFirst();

                ((FarthestFirst)ClustererToReturn).setNumClusters((int)Parameters.ListDoubleValues.Get("numericUpDownNumClasses").Value);
                ((FarthestFirst)ClustererToReturn).setSeed((int)Parameters.ListDoubleValues.Get("numericUpDownSeedNumber").Value);
                ClustererToReturn.buildClusterer(ListInstancesWithoutClasses);
                this.NumberOfClusters = ClustererToReturn.numberOfClusters();
            }
            #endregion
            #region CobWeb
            else if (ClusteringAlgo.Name == "CobWeb")
            {
                ClustererToReturn = new weka.clusterers.Cobweb();

                ((Cobweb)ClustererToReturn).setSeed((int)Parameters.ListDoubleValues.Get("numericUpDownSeedNumber").Value);
                ((Cobweb)ClustererToReturn).setAcuity((double)Parameters.ListDoubleValues.Get("numericUpDownAcuity").Value);
                ((Cobweb)ClustererToReturn).setCutoff((double)Parameters.ListDoubleValues.Get("numericUpDownCutOff").Value);
                ClustererToReturn.buildClusterer(ListInstancesWithoutClasses);

                this.NumberOfClusters = ClustererToReturn.numberOfClusters();
            }
            #endregion
            #region Manual
            else if (ClusteringAlgo.Name == "Manual")
            {
                string DescriptorName = (string)Parameters.ListTextValues.Get("comboBoxForDescriptorManualClustering").Value;

                //  this.Classes = new double[ListInstancesWithoutClasses.numInstances()];

                for (int IdxPt = 0; IdxPt < this.Classes.Count / 2; IdxPt++)
                {
                    this.Classes[IdxPt] = 2;
                }
                this.NumberOfClusters = 2;
                //    break;

                //int IdxDesc = -1;
                //foreach (string item in this.ListDescriptors)
                //{
                //    IdxDesc++;
                //    if (item == DescriptorName) break;
                //}

                //int Idx=0;

                //foreach (Instance item in ListInstancesWithoutClasses)
                //{
                //    this.Classes.Add(((int)item.value(IdxDesc)) % cGlobalInfo.ListCellularPhenotypes.Count);
                //}

                //// re - ordonner les valeurs du discripteur afin que les classes se suivent sans laisser de classe vide !!
                //this.NumberOfClusters =  cGlobalInfo.ListCellularPhenotypes.Count;
            }
            #endregion

            else
            {
                System.Windows.Forms.MessageBox.Show("Clustering method not implemented !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return null;
            }
            return ClustererToReturn;
        }
        private void buttonStartCluster_Click(object sender, EventArgs e)
        {
            FormSingleCellClusteringInfo WindowClusteringInfo = new FormSingleCellClusteringInfo(GlobalInfo);
            if (WindowClusteringInfo.ShowDialog() != System.Windows.Forms.DialogResult.OK) return;

            Instances ListInstances = GlobalInfo.CurrentScreen.CellBasedClassification.CreateInstancesWithoutClass(dt);
            if ((WindowClusteringInfo.radioButtonAutomated.Checked) && (WindowClusteringInfo.radioButtonEM.Checked))
            {
                ClusterEvaluation eval;
                Classes = new cExtendedList();
                weka.clusterers.EM EMCluster = new EM();
                if(WindowClusteringInfo.checkBoxEMAutomated.Checked)
                    EMCluster.setNumClusters(-1);
                else
                    EMCluster.setNumClusters((int)WindowClusteringInfo.numericUpDownClassNumber.Value);
                EMCluster.buildClusterer(ListInstances);
                EMCluster.getClusterModelsNumericAtts();

                eval = new ClusterEvaluation();
                eval.setClusterer(EMCluster);

                eval.evaluateClusterer(ListInstances);

                Classes.AddRange(eval.getClusterAssignments());
                NumClusters= eval.getNumClusters();
                ReDraw();
                FormForCellByCellClusteringResults WindowFormForCellByCellClusteringResults = new FormForCellByCellClusteringResults();
                WindowFormForCellByCellClusteringResults.richTextBoxResults.Clear();
                WindowFormForCellByCellClusteringResults.richTextBoxResults.AppendText(eval.clusterResultsToString());
                if (WindowFormForCellByCellClusteringResults.ShowDialog() != System.Windows.Forms.DialogResult.OK) return;

            }
            else if (WindowClusteringInfo.radioButtonDescriptorBased.Checked)
            {
                Classes = new cExtendedList();
                DataTable FinalDataTable = new DataTable();
                int IdxDescForClassSelect = WindowClusteringInfo.comboBoxDescriptorForClass.SelectedIndex;
                for (int IdxWell = 0; IdxWell < GlobalInfo.ListSelectedWell.Count; IdxWell++)
                {
                    cWell TmpWell = GlobalInfo.ListSelectedWell[IdxWell];

                 //   if (IdxWell == 0)
                    if (TmpWell.ListDescriptors[IdxDescForClassSelect].GetAssociatedType().DataType == eDataType.HISTOGRAM)
                    {
                        Classes.AddRange(TmpWell.ListDescriptors[IdxDescForClassSelect].GetOriginalValues());
                    }
                    else
                    {
                        double ClasseValue = TmpWell.ListDescriptors[IdxDescForClassSelect].GetValue();

                        for (int IdxCell = 0; IdxCell < TmpWell.CellNumber; IdxCell++)
                            Classes.Add(ClasseValue);
                        //TmpWell.AddDescriptors
                    }
                }

                List<double> ListClassValues = new List<double>();
                foreach (var item in Classes.Distinct())
                {
                    ListClassValues.Add(item);
                }

                    //(List<double>)Classes.Distinct();
                NumClusters = ListClassValues.Count();
                //Classes = new cExtendedList();
                for (int IdxClust = 0; IdxClust < Classes.Count; IdxClust++)
                {
                    for (int IdxCl = 0; IdxCl < ListClassValues.Count; IdxCl++)
                    {
                        if (ListClassValues[IdxCl] == Classes[IdxClust])
                        {
                            Classes[IdxClust] = IdxCl;
                            break;
                        }
                    }
                    //Classes[IdxClust] = ListClassValues.Find(Classes[IdxClust]);
                }
                //int NumClusters =
                ReDraw();

            }

            //    ReDraw();

            //if (MessageBox.Show("Do you want perform a j48 training process ?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != System.Windows.Forms.DialogResult.Yes) return;

            weka.core.FastVector attVals = new FastVector();
            for (int i = 0; i < NumClusters; i++)
                attVals.addElement("Class__" + (i).ToString());

            ListInstances.insertAttributeAt(new weka.core.Attribute("Class__", attVals), ListInstances.numAttributes());

            for (int i = 0; i < Classes.Count; i++)
            {
                ListInstances.get(i).setValue(ListInstances.numAttributes() - 1, Classes[i]);
            }
            ListInstances.setClassIndex(ListInstances.numAttributes() - 1);

               GlobalInfo.CurrentScreen.CellBasedClassification.ClassificationModel_CellBased = new weka.classifiers.trees.J48();
               GlobalInfo.CurrentScreen.CellBasedClassification.SetJ48Tree((weka.classifiers.trees.J48)GlobalInfo.CurrentScreen.CellBasedClassification.ClassificationModel_CellBased,Classes.Count);
               GlobalInfo.CurrentScreen.CellBasedClassification.J48Model.setMinNumObj((int)GlobalInfo.OptionsWindow.numericUpDownJ48MinNumObjects.Value);

            weka.core.Instances train = new weka.core.Instances(ListInstances, 0, ListInstances.numInstances());

            GlobalInfo.CurrentScreen.CellBasedClassification.ClassificationModel_CellBased.buildClassifier(train);
            GlobalInfo.ConsoleWriteLine(GlobalInfo.CurrentScreen.CellBasedClassification.ClassificationModel_CellBased.ToString());

               GlobalInfo.CurrentScreen.CellBasedClassification.evaluation = new weka.classifiers.Evaluation(ListInstances);
               GlobalInfo.CurrentScreen.CellBasedClassification.evaluation.crossValidateModel(GlobalInfo.CurrentScreen.CellBasedClassification.ClassificationModel_CellBased, ListInstances, 2, new java.util.Random(1));

            GlobalInfo.CurrentScreen.CellBasedClassification.DisplayTree(GlobalInfo).Show();

            FormForCellbyCellClassif WindowFormForCellbyCellClassif = new FormForCellbyCellClassif();
            if (WindowFormForCellbyCellClassif.ShowDialog() != System.Windows.Forms.DialogResult.OK) return;

            int DescrCount = GlobalInfo.CurrentScreen.ListDescriptors.Count;

            // first we update the descriptor
            for (int i = 0; i < ListInstances.numClasses(); i++)
                GlobalInfo.CurrentScreen.ListDescriptors.AddNew(new cDescriptorsType("Ratio_Class " + i, true, 1, GlobalInfo));

            FormForProgress ProgressWindow = new FormForProgress();
            ProgressWindow.Show();

            int IdxProgress = 0;
            int MaxProgress = 0;

            foreach (cPlate CurrentPlateToProcess in GlobalInfo.CurrentScreen.ListPlatesAvailable)
                MaxProgress += CurrentPlateToProcess.ParentScreening.Columns * CurrentPlateToProcess.ParentScreening.Rows;
            ProgressWindow.progressBar.Maximum = MaxProgress;

            attVals = new FastVector();
            for (int i = 0; i < NumClusters; i++)
                attVals.addElement(i.ToString());

            //ParallelOptions options = new ParallelOptions();
            //options.MaxDegreeOfParallelism = -1; // -1 is for unlimited. 1 is for sequential.
            //Stopwatch stopwatch = new Stopwatch();
            //stopwatch.Start();
            //////for (int PlateIdx = 0; PlateIdx < NumberOfPlates; PlateIdx++)
            //int NumberOfPlates = CompleteScreening.ListPlatesAvailable.Count;
            //Parallel.For(0, NumberOfPlates, options, (PlateIdx) =>
            //{
            //    cPlate CurrentPlateToProcess = CompleteScreening.ListPlatesActive.GetPlate((string)Parent.GlobalInfo.PlateListWindow.listBoxPlateNameToProcess.Items[PlateIdx]);

            //    for (int row = 0; row < Parent.Rows; row++)
            //        for (int col = 0; col < Parent.Columns; col++)
            //        {
            //            TempWell = CurrentPlateToProcess.GetWell(col, row, false);
            //            if (TempWell == null) continue;
            //            else
            //            {
            //                if (TempWell.GetClass() == this.ClassForClassif)
            //                    Pos.Add(TempWell.ListDescriptors[Parent.ListDescriptors.CurrentSelectedDescriptor].GetValue());
            //            }
            //        }
            //}
            //);

            foreach (cPlate CurrentPlateToProcess in GlobalInfo.CurrentScreen.ListPlatesAvailable)
            //Parallel.ForEach(GlobalInfo.CurrentScreen.ListPlatesActive, options, CurrentPlateToProcess =>
            {
                //Parallel.ForEach(CurrentPlateToProcess.ListActiveWells, options, TmpWell =>
                for(int j=0;j<CurrentPlateToProcess.ParentScreening.Rows;j++)
                    for (int k = 0; k < CurrentPlateToProcess.ParentScreening.Columns; k++)
                {
                    cWell TmpWell = CurrentPlateToProcess.GetWell(k, j, false);
                    if (TmpWell == null) continue;
                    ProgressWindow.progressBar.Value = IdxProgress++;

                    //DataTable FinalDataTable = new DataTable();
                    //TmpWell.AssociatedPlate.DBConnection = new cDBConnection(TmpWell.AssociatedPlate, TmpWell.SQLTableName);
                    //TmpWell.AssociatedPlate.DBConnection.AddWellToDataTable(TmpWell, FinalDataTable, false);
                    DataTable FinalDataTable = TmpWell.GetDescDataTable(true);
                    Instances ListInstancesTOClassify = GlobalInfo.CurrentScreen.CellBasedClassification.CreateInstancesWithoutClass(FinalDataTable);

                    ListInstancesTOClassify.insertAttributeAt(new weka.core.Attribute("Class", attVals), ListInstancesTOClassify.numAttributes());
                    ListInstancesTOClassify.setClassIndex(ListInstancesTOClassify.numAttributes() - 1);

                    cExtendedList ListClasses = new cExtendedList();

                    for (int i = 0; i < ListInstancesTOClassify.numInstances(); i++)
                    {
                        double classId = GlobalInfo.CurrentScreen.CellBasedClassification.ClassificationModel_CellBased.classifyInstance(ListInstancesTOClassify.instance(i));
                        ListClasses.Add(classId);
                    }
                    List<double[]> Histo = ListClasses.CreateHistogram(0, ListInstances.numClasses() - 1, ListInstances.numClasses() - 1);
                    List<cDescriptor> LDesc = new List<cDescriptor>();

                    for (int IdxHisto = 0; IdxHisto < Histo[1].Length; IdxHisto++)
                    {
                        double Value = (100.0 * Histo[1][IdxHisto]) / (double)ListInstancesTOClassify.numInstances();

                        cDescriptor NewDesc = new cDescriptor(Value, GlobalInfo.CurrentScreen.ListDescriptors[IdxHisto + DescrCount], GlobalInfo.CurrentScreen);
                        LDesc.Add(NewDesc);
                    }

                    TmpWell.AddDescriptors(LDesc);
                    //TmpWell.AssociatedPlate.DBConnection.DB_CloseConnection();

                }//);
            }
            ProgressWindow.Close();

            if (WindowFormForCellbyCellClassif.checkBoxKeepOriginalDesc.Checked == false)
            {

               // int DescNumToRemove = GlobalInfo.CurrentScreen.ListDescriptors.Count -
                for (int IdxDesc = 0; IdxDesc < DescrCount; IdxDesc++)
                GlobalInfo.CurrentScreen.ListDescriptors.RemoveDesc(GlobalInfo.CurrentScreen.ListDescriptors[0], GlobalInfo.CurrentScreen);

            }

            GlobalInfo.CurrentScreen.ListDescriptors.UpDateDisplay();
            GlobalInfo.CurrentScreen.UpDatePlateListWithFullAvailablePlate();

            for (int idxP = 0; idxP < GlobalInfo.CurrentScreen.ListPlatesActive.Count; idxP++)
                GlobalInfo.CurrentScreen.ListPlatesActive[idxP].UpDataMinMax();

            if (WindowFormForCellbyCellClassif.checkBoxKeepOriginalDesc.Checked == false)
                GlobalInfo.CurrentScreen.GetCurrentDisplayPlate().DisplayDistribution(0, false);

            //WindowFormForCellbyCellClassif.Close();
            //WindowClusteringInfo.Close();
        }
Example #39
0
        /// <summary>
        /// Perform an EM clustering on each plate independantely
        /// </summary>
        /// <param name="CurrentPlateToProcess">the plate to process</param>
        /// <param name="ClassNumber">Number of class</param>
        private void ClusteringEMSinglePlate(cPlate CurrentPlateToProcess, int ClassNumber)
        {
            weka.core.Instances Ninsts = CurrentPlateToProcess.CreateInstancesWithoutClass();// CreateInstanceWithoutClass(CurrentTable);

            weka.clusterers.EM EMCluster = new EM();
            EMCluster.setNumClusters(ClassNumber);

            EMCluster.buildClusterer(Ninsts);
            EMCluster.getClusterModelsNumericAtts();
            if (EMCluster.numberOfClusters() > GlobalInfo.GetNumberofDefinedClass())
            {
                richTextBoxInfoClustering.AppendText("\n Plate " + CurrentPlateToProcess.Name + ", cluster Number: more than " + GlobalInfo.GetNumberofDefinedClass() + ", clustering not operated.\n");
                return;
            }
            else
                richTextBoxInfoClustering.AppendText("\n" + CurrentPlateToProcess.Name + ": " + EMCluster.numberOfClusters() + " cluster(s)");

            ClusterEvaluation eval = new ClusterEvaluation();
            eval.setClusterer(EMCluster);
            eval.evaluateClusterer(Ninsts);

            CurrentPlateToProcess.AssignClass(eval.getClusterAssignments());
        }