Example #1
0
        private double rateSplit(AttributeTable first, AttributeTable second, ClassCounter allTable)
        {
            ClassCounter firstCounter  = new ClassCounter(first);
            ClassCounter secondCounter = new ClassCounter(second);

            return(firstCounter.calculateGiniSplit(allTable) + secondCounter.calculateGiniSplit(allTable));
        }
Example #2
0
        private Tuple <AttributeTable, AttributeTable> splitTableNumerical(int i)
        {
            AttributeTable first  = new AttributeTable(attributes.GetRange(0, i), isNumerical);
            AttributeTable second = new AttributeTable(attributes.GetRange(i, attributes.Count - i), isNumerical);
            Tuple <AttributeTable, AttributeTable> toReturn = new Tuple <AttributeTable, AttributeTable>(first, second);

            return(toReturn);
        }
Example #3
0
 public ClassCounter(AttributeTable table)
 {
     classes  = new List <string>();
     counters = new List <int>();
     foreach (var v in table.Attributes)
     {
         addClass(v.AttributeClass);
     }
 }
Example #4
0
        private Tuple <AttributeTable, AttributeTable> splitTableString(string s)
        {
            int a = 0;
            int b = 0;

            for (int i = 0; i < attributes.Count; i++)
            {
                if (attributes[i].getValueAsString().Equals(s))
                {
                    a = i;
                    break;
                }
            }

            for (int i = a; i < attributes.Count; i++)
            {
                if (attributes[i].getValueAsString().Equals(s))
                {
                    b++;
                }
                else
                {
                    break;
                }
            }

            List <DataAttribute> leftList  = new List <DataAttribute>();
            List <DataAttribute> rightList = new List <DataAttribute>();

            rightList.AddRange(attributes.GetRange(0, a));
            leftList.AddRange(attributes.GetRange(a, b));
            rightList.AddRange(attributes.GetRange(a + b, attributes.Count - a - b));

            AttributeTable leftTable  = new AttributeTable(leftList, isNumerical);
            AttributeTable rightTable = new AttributeTable(rightList, isNumerical);

            Tuple <AttributeTable, AttributeTable> toReturn = new Tuple <AttributeTable, AttributeTable>(leftTable, rightTable);

            return(toReturn);
        }