コード例 #1
0
        public void TestPredictMethod()
        {
            TestTrainValidData();
            object predicted = NaiveBayesModel.Predict(new List <object> {
                "Sunny"
            });
            string predictedRes = predicted as string;

            Assert.AreEqual(predictedRes, "Yes");
        }
コード例 #2
0
        public void Deveria_prever_com_cem_porcento_de_probabildade_quando_dado_fornecido_for_igual_ao_dado_treinado()
        {
            var play = new PlayBasketball
            {
                HasBall         = true,
                NumberOfPlayers = 4,
                Rain            = false,
                Windy           = false,
                CanPlay         = true
            };

            _naiveBayes.Add(play);

            _naiveBayes.Fit();

            decimal probability = _naiveBayes.Predict(play);

            probability.Should().Be(1);
        }
コード例 #3
0
        public List <string> PredictKeywords(List <List <string> > sentencePosTokensIn)
        {
            List <string> retKeywords = new List <string>();
            var           examples    = SplitInputIntoExamples(sentencePosTokensIn);
            int           currIndex   = 1; //the element directly after the START token

            foreach (List <string> example in examples)
            {
                List <object> objExample = new List <object>();
                foreach (string x in example)
                {
                    objExample.Add(x);
                }
                object res = Model.Predict(objExample);
                if ((bool)res)
                {
                    retKeywords.Add(sentencePosTokensIn[currIndex][0]);
                }
                currIndex++;
            }
            return(retKeywords);
        }