NClassifier.Bayesian.BayesianClassifier.Classify C# (CSharp) 메소드

Classify() 공개 메소드

public Classify ( string input ) : double
input string
리턴 double
        public override double Classify(string input)
        {
            return Classify(ICategorizedClassifierConstants.DEFAULT_CATEGORY, input);
        }

Same methods

BayesianClassifier::Classify ( string category, string input ) : double

Usage Example

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

            var sentence = new[] { "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);
        }