Ejemplo n.º 1
0
        public void ApplyTest()
        {
            DataTable data = new DataTable("Sample data");

            data.Columns.Add("x", typeof(double));
            data.Columns.Add("Class", typeof(int));
            data.Rows.Add(0.21, 0);
            data.Rows.Add(0.25, 0);
            data.Rows.Add(0.54, 0);
            data.Rows.Add(0.19, 1);

            DataTable expected = new DataTable("Sample data");

            expected.Columns.Add("x", typeof(double));
            expected.Columns.Add("Class", typeof(int));
            expected.Rows.Add(0.21, 0);
            expected.Rows.Add(0.25, 0);
            expected.Rows.Add(0.54, 0);
            expected.Rows.Add(0.19, 1);
            expected.Rows.Add(0.19, 1);
            expected.Rows.Add(0.19, 1);


            DataTable actual;

            Equalization target = new Equalization("Class");

            target.Columns["Class"].Classes = new int[] { 0, 1 };

            actual = target.Apply(data);

            for (int i = 0; i < actual.Rows.Count; i++)
            {
                double ex = (double)expected.Rows[i][0];
                int    ec = (int)expected.Rows[i][1];

                double ax = (double)actual.Rows[i][0];
                int    ac = (int)actual.Rows[i][1];

                Assert.AreEqual(ex, ax);
                Assert.AreEqual(ec, ac);
            }
        }
Ejemplo n.º 2
0
        public void ApplyTest()
        {
            DataTable data = new DataTable("Sample data");
            data.Columns.Add("x", typeof(double));
            data.Columns.Add("Class", typeof(int));
            data.Rows.Add(0.21, 0);
            data.Rows.Add(0.25, 0);
            data.Rows.Add(0.54, 0);
            data.Rows.Add(0.19, 1);

            DataTable expected = new DataTable("Sample data");
            expected.Columns.Add("x", typeof(double));
            expected.Columns.Add("Class", typeof(int));
            expected.Rows.Add(0.21, 0);
            expected.Rows.Add(0.25, 0);
            expected.Rows.Add(0.54, 0);
            expected.Rows.Add(0.19, 1);
            expected.Rows.Add(0.19, 1);
            expected.Rows.Add(0.19, 1);


            DataTable actual;

            Equalization target = new Equalization("Class");
            target.Columns["Class"].Classes = new int[] { 0, 1 };
            
            actual = target.Apply(data);

            for (int i = 0; i < actual.Rows.Count; i++)
            {
                double ex = (double)expected.Rows[i][0];
                int ec = (int)expected.Rows[i][1];

                double ax = (double)actual.Rows[i][0];
                int ac = (int)actual.Rows[i][1];

                Assert.AreEqual(ex, ax);
                Assert.AreEqual(ec, ac);                    
                
            }
            
        }