Пример #1
0
        public void TestWithDataYouveNeverSeen_StillWorks()
        {
            DecisionTreeLevel decisionTree = new DecisionTreeLevel(0);

            decisionTree.D3(_generic3BooleanAttributes,
                            new List <DataSetValue>()
            {
                new DataSetValue(new List <string>()
                {
                    "0", "0", "0"
                }, false),
                new DataSetValue(new List <string>()
                {
                    "0", "0", "1"
                }, true),
                new DataSetValue(new List <string>()
                {
                    "0", "1", "0"
                }, false),
                new DataSetValue(new List <string>()
                {
                    "0", "1", "1"
                }, false),
                new DataSetValue(new List <string>()
                {
                    "1", "0", "0"
                }, false),
                new DataSetValue(new List <string>()
                {
                    "1", "0", "1"
                }, false),
                new DataSetValue(new List <string>()
                {
                    "1", "1", "0"
                }, false),
                new DataSetValue(new List <string>()
                {
                    "1", "1", "1"
                }, false),
            });

            decisionTree.Evaluate(new List <string>()
            {
                "0", "0", "JORGE"
            }).Should().BeFalse();
        }
Пример #2
0
        private void VerifyDecisionTreeCanLearnTable(List <DataSetValue> tableToLearn)
        {
            DecisionTreeLevel decisionTree = new DecisionTreeLevel(0);

            decisionTree.D3(_generic3BooleanAttributes, tableToLearn);
            decisionTree.TrimTree();

            // The tree should have learnt every value
            foreach (var dataSetValue in tableToLearn)
            {
                decisionTree.Evaluate(dataSetValue.Values).Should().Be(dataSetValue.Output);
            }

            // Break here to visualize decision tree
            string visualizedDecisionTree = decisionTree.SerializeDecisionTree();

            Debug.WriteLine("Visualized decision tree:\n" + visualizedDecisionTree);
        }