Example #1
0
        private void InitializeData(int index)
        {
            Classter.VFound(IAM);
            if (index < 0 || index >= IAM.ISA.Count)
            {
                return;
            }
            Classters.Clear();
            int parse;

            for (int i = 0; i < IAM.ISA[index].unsortl.Length; i++)
            {
                if (int.TryParse(IAM.ISA[index].unsortl[i].ToString(), out parse) != true)
                {
                    return;
                }
            }
            for (int i = 0; i <= IAM.ISA[index].Max.Q; i++)
            {
                Classters.Add(new Classter(n));
            }
            Data = new List <double[]>();
            for (int i = 0; i < IAM.N; i++)
            {
                double[] value = new double[n];
                for (int j = 0; j < n; j++)
                {
                    value[j] = IAM.Xall[i, j >= index ? j + 1 : j];
                }
                Data.Add(value);
                Classters[(int)IAM.Xall[i, index]].Add(value);
            }
            try
            {
                Classter.IAMFound(Classters.ToArray());
            }
            catch
            {
                Classters.Clear();
                return;
            }
            SetData();

            if (n == 2)
            {
                chart.Series.Clear();
                Classter.DrawClassters(chart, Classters.ToArray());
            }

            pDataGridView.ColumnCount = Classters.Count;
            pDataGridView.Rows.Add();
            for (int i = 0; i < Classters.Count; i++)
            {
                pDataGridView.Columns[i].Width = 45;
                pDataGridView[i, 0].Value      = "1";
            }

            Classter.QFound(Classters.ToArray());
            ShowQ(Classter.Q);
        }
        private void Classterizate_Click(object sender, EventArgs e)
        {
            Classter.ChangeD(TypeDComboBox.Text);
            Classter.ChangeDSS(TypeDSSComboBox.Text);

            Classter.VFound(IAM);

            if (MethodComboBox.SelectedIndex == 0)
            {
                if (Classters.Count < 2)
                {
                    return;
                }
                KAverage();
            }
            else if (MethodComboBox.SelectedIndex == 1)
            {
                AdditionalInformationForm AIF = new AdditionalInformationForm("Введіть K");
                int index;
                try
                { index = Convert.ToInt32(AIF.getString()); }
                catch
                { return; }
                AgmomerativClassterizate(index > 1 ? index : 2);
            }

            if (IAM.n == 2)
            {
                chart.Series[0].Enabled = chart.Series[1].Enabled = Classterizate.Visible = false;
            }
            int MaxGroup = -1;

            for (int j = 0; j < ML.Count; j++)
            {
                MaxGroup = Math.Max(MaxGroup, ML[j].Group);
            }
            for (int i = 0; i < Classters.Count; i++)
            {
                InitialStatisticalAnalys[] ISA = Classters[i].ToISA(MaxGroup + i + 1);
                if (IAM.n == 2)
                {
                    chart.Series.Add(
                        PaintData.CorelPaint(ISA[0].unsortl, ISA[1].unsortl, GetColor(i),
                                             "Classter" + (i + 1).ToString()));
                    chart.Series[chart.Series.Count - 1].MarkerSize = 10;
                }
                for (int j = 0; j < ISA.Length; j++)
                {
                    ML.Add(ISA[j]);
                    undolist.Add(ML[ML.Count - 1].unsortl);
                }
            }
            WraitData.RefreshList(treeView1, ML);

            Classter.QFound(Classters.ToArray());
            ShowQ(Classter.Q);
        }