A naive bayes generator.
Inheritance: Generator
        public void Tennis_Naive_Bayes_Save_And_Load_Test()
        {
            var data = Tennis.GetData();
            var description = Descriptor.Create<Tennis>();
            var generator = new NaiveBayesGenerator(2);
            var model = generator.Generate(description, data);
            Serialize(model);

            var lmodel = Deserialize<NaiveBayesModel>();
        }
        public void Iris_Naive_Bayes_Save_And_Load_Test()
        {
            var data = Iris.Load();
            var description = Descriptor.Create<Iris>();
            var generator = new NaiveBayesGenerator(2);
            var model = generator.Generate(description, data) as NaiveBayesModel;

            Serialize(model);

            var lmodel = Deserialize<NaiveBayesModel>();
            Assert.Equal(model.Root, lmodel.Root);
        }
Esempio n. 3
0
        public void Main_Naive_Bayes_Test()
        {
            var data = Tennis.GetData();
            var description = Descriptor.Create<Tennis>();
            var generator = new NaiveBayesGenerator(2);
            var model = generator.Generate(description, data);

            Tennis t = new Tennis
            {
                Humidity = Humidity.Normal,
                Outlook = Outlook.Overcast,
                Temperature = Temperature.Cool,
                Windy = true
            };

            model.Predict<Tennis>(t);
            Assert.IsTrue(t.Play);
        }
Esempio n. 4
0
        public void Iris_DT_and_Prediction()
        {
            var data = Iris.Load();
            var description = Descriptor.Create<Iris>();
            var generator = new NaiveBayesGenerator(2);
            var model = generator.Generate(description, data);

            // should be Iris-Setosa
            Iris iris = new Iris
            {
                SepalLength = 2.1m,
                SepalWidth = 2.2m,
                PetalWidth = 0.5m,
                PetalLength = 2.3m,
            };

            iris = model.Predict<Iris>(iris);
            Assert.AreEqual("Iris-setosa".Sanitize(), iris.Class);
        }