Example #1
0
        private void button3_Click(object sender, EventArgs e)
        {
            string s = textBox3.Text;
            int    b;
            string v;

            for (int i = 0; i < s.Length; i++)
            {
                if (Char.IsDigit(s[i]))
                {
                    v = Convert.ToString(s[i]);
                    b = int.Parse(v);
                    columnss pnn = new columnss();
                    pnn.c = b;
                    columns.Add(pnn);
                }
            }


            for (int i = 0; i < dataGridView1.RowCount - 1; i++)
            {
                total = 0;
                for (int j = 0; j < columns.Count; j++)
                {
                    temp   = 0;
                    p1     = 0;
                    p1     = Convert.ToSingle(dataGridView1.Rows[i].Cells[j].Value);
                    classs = Convert.ToSingle(dataGridView1.Rows[i].Cells[columns.Count].Value);
                    temp   = columns[j].c - p1;
                    total += temp * temp;
                }
                actor pnn = new actor();
                pnn.value  = total;
                pnn.classs = classs;
                d.Add(pnn);
            }
            d.Sort();
            int max   = -999999;
            int ct    = 0;
            int count = Convert.ToInt32(textBox7.Text);

            for (int i = 0; i < count; i++)
            {
                ct = 0;
                for (int j = 0; j < count; j++)
                {
                    if (d[i].classs == d[j].classs)
                    {
                        ct++;
                        if (ct > max)
                        {
                            max          = ct;
                            mostrepeated = d[i].classs;
                        }
                    }
                }
            }
            for (int i = 0; i < count; i++)
            {
                MessageBox.Show("d: " + d[i].value + "c: " + d[i].classs);
            }
            MessageBox.Show("most repeated class is:  " + mostrepeated);
        }
Example #2
0
        private void button3_Click(object sender, EventArgs e)
        {
            string s = textBox3.Text;
            int    b;
            string v;

            for (int i = 0; i < s.Length; i++)
            {
                if (Char.IsDigit(s[i]))
                {
                    v = Convert.ToString(s[i]);
                    b = int.Parse(v);
                    columnss pnn = new columnss();
                    pnn.c = b;
                    columns.Add(pnn);
                }
            }
            for (int i = 0; i < dataGridView1.RowCount - 1; i++)
            {
                total = 0;
                for (int j = 0; j < columns.Count; j++)
                {
                    temp   = 0;
                    p1     = 0;
                    p1     = Convert.ToSingle(dataGridView1.Rows[i].Cells[j].Value);
                    classs = Convert.ToSingle(dataGridView1.Rows[i].Cells[columns.Count].Value);
                    temp   = columns[j].c - p1;
                    total += temp * temp;
                }
                actor pnn = new actor();
                pnn.value  = total;
                pnn.classs = classs;
                d.Add(pnn);
            }
            m = Convert.ToInt32(textBox7.Text);

            power = 2 / (m - 1);
            for (int i = 0; i < d.Count; i++)
            {
                tot  = 0;
                tot1 = 0;
                for (int j = 0; j < d.Count; j++)
                {
                    if (d[i].classs == d[j].classs && i != j && d[j].visited == 0)
                    {
                        d[j].visited = 1;
                        Base         = Math.Pow(power, d[i].value);
                        all          = 1 / Base;
                        tot         += all;
                    }
                }
                for (int k = 0; k < d.Count; k++)
                {
                    Base1 = Math.Pow(power, d[i].value);
                    all1  = 1 / Base;
                    tot1 += all;
                }

                actor pnn = new actor();
                pnn.value  = tot / tot1;
                pnn.classs = d[i].classs;
                ms.Add(pnn);
            }
            for (int l = 0; l < ms.Count; l++)
            {
                if (ms[l].value > max)
                {
                    max         = ms[l].value;
                    belongclass = ms[l].classs;
                }
            }
            MessageBox.Show("belonged class:  " + belongclass);
        }