Ejemplo n.º 1
0
        public void NaiveBayes_jason_all_training_samples()
        {
            initData_dataset_naive_bayes_jason_example();

            BuildNaiveBayes bnb   = new BuildNaiveBayes();
            ModelBase       model = (ModelBase)bnb.BuildModel
                                        (_trainingData, _attributeHeaders, _indexTargetAttribute);

            double[] data;
            double   value;
            int      count = 0;

            data = new double[_trainingData.Length - 1];
            for (int row = 0; row < _trainingData[0].Length; row++)
            {
                for (int col = 0; col < _trainingData.Length - 1; col++)
                {
                    data[col] =
                        _trainingData[col][row];
                }
                value = model.RunModelForSingleData(data);
                if (value == _trainingData[_indexTargetAttribute][row])
                {
                    count++;
                }
            }

            Assert.AreEqual(count, 8);
        }
Ejemplo n.º 2
0
        public void NaiveBayes_jason_single_training_sample_negative()
        {
            initData_dataset_naive_bayes_jason_example();

            BuildNaiveBayes bnb = new BuildNaiveBayes();

            ModelBase model = (ModelBase)bnb.BuildModel
                                  (_trainingData, _attributeHeaders, _indexTargetAttribute);

            double[] data;
            double   value;

            data = new double[_trainingData.Length - 1];
            for (int col = 0; col < _trainingData.Length - 1; col++)
            {
                data[col] =
                    _trainingData[col][1];
            }

            value = model.RunModelForSingleData(data);

            Assert.AreNotEqual(value, _trainingData[_indexTargetAttribute][1]);
        }