Beispiel #1
0
        public DecisionTree(DataSet DataSet, int Target)
        {
            KeyValuePair <AttributeValue, bool> S = DataSet.SingularValue(Target);

            if (S.Value)
            {
                _Value = S.Key;
            }
            else
            {
                _Check = DataSet.BestGain(Target);
                if (_Check == null)
                {
                    _Value = DataSet.MostCommonValue(Target);
                    return;
                }
                _Children = new List <KeyValuePair <AttributeValue, DecisionTree> >();
                List <AttributeValue> A = DataSet.SortedValues(_Check.Function);
                foreach (AttributeValue V in A)
                {
                    DecisionTree C = new DecisionTree(DataSet.Subset(_Check.Function, V), Target);
                    _Children.Add(new KeyValuePair <AttributeValue, DecisionTree>(V, C));
                }
            }
        }
Beispiel #2
0
 public DecisionTree(DataSet DataSet, int Target)
 {
     KeyValuePair<AttributeValue, bool> S = DataSet.SingularValue(Target);
     if (S.Value) _Value = S.Key;
     else
     {
         _Check = DataSet.BestGain(Target);
         if (_Check == null)
         {
             _Value = DataSet.MostCommonValue(Target);
             return;
         }
         _Children = new List<KeyValuePair<AttributeValue, DecisionTree>>();
         List<AttributeValue> A = DataSet.SortedValues(_Check.Function);
         foreach (AttributeValue V in A)
         {
             DecisionTree C = new DecisionTree(DataSet.Subset(_Check.Function, V), Target);
             _Children.Add(new KeyValuePair<AttributeValue, DecisionTree>(V, C));
         }
     }
 }