Exemple #1
0
        static void Main(string[] args)
        {
            DataTable table = new DataTable();

            table.Columns.Add("Sex");
            table.Columns.Add("Height", typeof(double));
            table.Columns.Add("Weight", typeof(double));
            table.Columns.Add("FootSize", typeof(double));

            //training data.
            table.Rows.Add("male", 6, 180, 12);
            table.Rows.Add("male", 5.92, 190, 11);
            table.Rows.Add("male", 5.58, 170, 12);
            table.Rows.Add("male", 5.92, 165, 10);

            table.Rows.Add("female", 5, 100, 6);
            table.Rows.Add("female", 5.5, 150, 8);
            table.Rows.Add("female", 5.42, 130, 7);
            table.Rows.Add("female", 5.75, 150, 9);

            BayesClassifier classifier = new BayesClassifier();

            classifier.TrainClassifier(table);

            Console.WriteLine(classifier.Classify(new double[] { 4, 150, 12 }));
            Console.Read();
        }
        public void ClassifyTest()
        {
            String text   = "雁塔王家村民房凌晨突发火灾 4人死亡13人受伤";
            int    result = BayesClassifier.Classify(text);

            Console.WriteLine(result);
        }
        public static SentimentAnalysisData AnalyzeReview(ReviewData data)
        {
            SentimentAnalysisData result = new SentimentAnalysisData {
                Review = data
            };

            result.SentimentEvaluation = int.Parse(classifier.Classify(result.Review.reviewText));
            return(result);
        }
Exemple #4
0
        protected Int16 Judgement(String Title)
        {
            //IsAccident isAccident = new IsAccident(Title);
            //if (isAccident.isAccResu)
            //    return 0;
            //每判断一个类别,插入一个类别
            // BayesClassifier classifier = new BayesClassifier();// 构造Bayes分类器
            Int16 result = BayesClassifier.Classify(Title);// 进行分类

            return(result);
        }