public void TestClassify()
        {
            SimpleWordsDataSource wds        = new SimpleWordsDataSource();
            BayesianClassifier    classifier = new BayesianClassifier(wds);

            string[] sentence = new string[] { "This", "is", "a", "sentence", "about", "java" };

            Assert.AreEqual(IClassifierConstants.NEUTRAL_PROBABILITY, classifier.Classify(ICategorizedClassifierConstants.DEFAULT_CATEGORY, sentence), 0d);

            wds.SetWordProbability(new WordProbability("This", .5d));
            wds.SetWordProbability(new WordProbability("is", .5d));
            wds.SetWordProbability(new WordProbability("a", .5d));
            wds.SetWordProbability(new WordProbability("sentence", .2d));
            wds.SetWordProbability(new WordProbability("about", .5d));
            wds.SetWordProbability(new WordProbability("java", .99d));

            Assert.AreEqual(.96d, classifier.Classify(ICategorizedClassifierConstants.DEFAULT_CATEGORY, sentence), .009d);
        }
Exemplo n.º 2
0
        public void ClassifierTest()
        {
            var bc = new BayesianClassifier <int>();

            bc.SetFeatureProbability(10, .50d);
            bc.SetFeatureProbability(20, .2d);
            bc.SetFeatureProbability(30, .50d);
            bc.SetFeatureProbability(69, .99d);

            var set = bc.Classify(new[] { 10, 20, 30, 69 });

            Assert.NotNull(set);
            Assert.AreEqual(1, set.Count);

            var r = set.ElementAt(0);

            Assert.AreEqual(.96d, r.Probability, .009d);
        }
        public void ClassifierTest() {

            var bc = new BayesianClassifier<int>();

            bc.SetFeatureProbability(10, .50d);
            bc.SetFeatureProbability(20, .2d);
            bc.SetFeatureProbability(30, .50d);
            bc.SetFeatureProbability(69, .99d);

            var set = bc.Classify(new[] { 10, 20, 30, 69 });

            Assert.NotNull(set);
            Assert.AreEqual(1, set.Count);

            var r = set.ElementAt(0);

            Assert.AreEqual(.96d, r.Probability, .009d);

        }