static DataSet GenerateData(int DataSize) { DataSet R = new DataSet(5); for (int c = 0; c < DataSize; ++c) { R.AddEntry(GenerateEntry()); } return R; }
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)); } } }
public void VerifyPlay(Card DownCard, Card Played, bool Valid) { AttributeValue[] Entry = new AttributeValue[5]; Entry[0] = new IntegerValue(DownCard.Number); Entry[1] = new IntegerValue(DownCard.Suit); Entry[2] = new IntegerValue(Played.Number); Entry[3] = new IntegerValue(Played.Suit); Entry[4] = new BooleanValue(Valid); if (_Forest == null) _Forest = new Forest(1, 1, delegate(int i) { DataSet D = new DataSet(5); D.AddEntry(Entry); return D; }, 4); else _Forest.AddEntry(Entry); }