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);
        }
Example #2
0
 private static AbyStruct AbyAverageWeighted(Classter Sl, Classter Sh, Classter Sm)
 {
     return(new AbyStruct {
         al = (double)Sl.data.Count / (Sl.data.Count + Sh.data.Count),
         ah = (double)Sh.data.Count / (Sl.data.Count + Sh.data.Count),
         beta = 0, gama = 0
     });
 }
        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);
        }
Example #4
0
 private static AbyStruct AbyYorda(Classter Sl, Classter Sh, Classter Sm)
 {
     return(new AbyStruct
     {
         al = (double)(Sm.data.Count + Sl.data.Count) / (Sm.data.Count + Sl.data.Count + Sh.data.Count),
         ah = (double)(Sm.data.Count + Sh.data.Count) / (Sm.data.Count + Sl.data.Count + Sh.data.Count),
         beta = -(double)Sm.data.Count / (Sm.data.Count + Sl.data.Count + Sh.data.Count),
         gama = 0
     });
 }
Example #5
0
 private static AbyStruct AbyCenter(Classter Sl, Classter Sh, Classter Sm)
 {
     return(new AbyStruct
     {
         al = (double)Sl.data.Count / (Sl.data.Count + Sh.data.Count),
         ah = (double)Sh.data.Count / (Sl.data.Count + Sh.data.Count),
         beta = -(double)Sh.data.Count * Sl.data.Count / Math.Pow(Sl.data.Count + Sh.data.Count, 2),
         gama = 0
     });
 }
Example #6
0
 private static AbyStruct AbyMediana(Classter Sl, Classter Sh, Classter Sm)
 {
     return(new AbyStruct
     {
         al = 0.5,
         ah = 0.5,
         beta = -0.25,
         gama = 0
     });
 }
Example #7
0
 private static AbyStruct AbyAverageNotWeighted(Classter Sl, Classter Sh, Classter Sm)
 {
     return(new AbyStruct
     {
         al = 0.5,
         ah = 0.5,
         beta = 0,
         gama = 0
     });
 }
Example #8
0
        static public double DSSS(Classter Sl, Classter Sh, Classter Sm)
        {
            AbyStruct abyData = aby(Sl, Sh, Sm);

            double[] dSSarray = new double[] { dSS(Sl, Sm), dSS(Sh, Sm), dSS(Sl, Sh), Math.Abs(dSS(Sh, Sm) - dSS(Sl, Sm)) };
            return(abyData.al * dSSarray[0] +
                   abyData.ah * dSSarray[1] +
                   abyData.beta * dSSarray[2] +
                   abyData.gama * dSSarray[3]);
        }
Example #9
0
        private static double DSSAverageNotWeighted(Classter S1, Classter S2)
        {
            double sum = 0;

            for (int l1 = 0; l1 < S1.data.Count; l1++)
            {
                for (int l2 = 0; l2 < S2.data.Count; l2++)
                {
                    sum += d(S1.data[l1], S2.data[l2]);
                }
            }
            return(sum / (4.0));
        }
Example #10
0
        private static double DSSMaxNeighborhood(Classter S1, Classter S2)
        {
            double max = double.MinValue;

            for (int l1 = 0; l1 < S1.data.Count; l1++)
            {
                for (int l2 = 0; l2 < S2.data.Count; l2++)
                {
                    max = Math.Max(max, d(S1.data[l1], S2.data[l2]));
                }
            }
            return(max);
        }
Example #11
0
        static public Classter Merge(Classter C1, Classter C2)
        {
            Classter result = new Classter(C1.data[0]);

            for (int i = 1; i < C1.data.Count; i++)
            {
                result.Add(C1.data[i]);
            }
            for (int i = 0; i < C2.data.Count; i++)
            {
                result.Add(C2.data[i]);
            }
            return(result);
        }
Example #12
0
        private void AgmomerativClassterizate(int K)
        {
            List <Classter> classters = new List <Classter>();

            for (int i = 0; i < Data.Count; i++)
            {
                classters.Add(new Classter(Data[i]));
            }
            DataGridView datagrid = new DataGridView()
            {
                AllowUserToAddRows = false
            };

            datagrid.ColumnCount = classters.Count;
            datagrid.Rows.Add(classters.Count);
            for (int c = 0; c < classters.Count; c++)
            {
                for (int r = c; r < classters.Count; r++)
                {
                    double len = Classter.d(classters[c].Center, classters[r].Center);
                    datagrid[c, r].Value = len == 0 ? double.MaxValue: len;
                    datagrid[r, c].Value = datagrid[c, r].Value;
                }
            }
            while (datagrid.ColumnCount != K)
            {
                Point index = IndexMinValueDataGrid(datagrid);

                datagrid.Columns.Add("NewCol" + datagrid.ColumnCount.ToString(), "");
                datagrid.Rows.Add();
                classters.Add(Classter.Merge(classters[index.X], classters[index.Y]));

                for (int i = 0; i < classters.Count; i++)
                {
                    double len = Classter.DSSS(classters[index.X], classters[index.Y], classters[i]);
                    datagrid[datagrid.ColumnCount - 1, i].Value = len == 0 ? double.MaxValue : len;
                    datagrid[i, datagrid.Rows.Count - 1].Value  = datagrid[datagrid.ColumnCount - 1, i].Value;
                }

                classters.RemoveAt(Math.Max(index.X, index.Y));
                datagrid.Columns.RemoveAt(Math.Max(index.X, index.Y));
                datagrid.Rows.RemoveAt(Math.Max(index.X, index.Y));

                classters.RemoveAt(Math.Min(index.X, index.Y));
                datagrid.Columns.RemoveAt(Math.Min(index.X, index.Y));
                datagrid.Rows.RemoveAt(Math.Min(index.X, index.Y));
            }
            Classters = classters;
        }
Example #13
0
 private static double DSSYorda(Classter S1, Classter S2)
 {
     double[] Ce1 = S1.Center;
     double[] Ce2 = S2.Center;
     return(Math.Pow(d(Ce1, Ce2), 2) * S1.data.Count * S2.data.Count / (S1.data.Count + S2.data.Count));
 }
Example #14
0
 private static double DSSCenter(Classter S1, Classter S2)
 {
     double[] Ce1 = S1.Center;
     double[] Ce2 = S2.Center;
     return(d(Ce1, Ce2));
 }
Example #15
0
 private static double DSSMediana(Classter S1, Classter S2)
 {
     double[] Me1 = S1.Mediana();
     double[] Me2 = S2.Mediana();
     return(d(Me1, Me2) / 2.0);
 }
Example #16
0
 private static AbyStruct AbyMaxNeighborhood(Classter Sl, Classter Sh, Classter Sm)
 {
     return(new AbyStruct {
         ah = 0.5, al = 0.5, beta = 0, gama = 0.5
     });
 }