Esempio n. 1
0
        public void BalancedBinaryClassificationRandomForestLearnerThrowsForWrongLabel(
            double firstLabel,
            double secondLabel,
            double thirdLabel,
            double fourthLabel)
        {
            var trainDataObservations = new F64Matrix(
                new[]
            {
                1.0,
                2.0,
                3.0,
                4.0,
                5.0,
                6.0,
                7.0,
                8.0,
            },
                4,
                2);
            var trainDataLabels = new[] { firstLabel, secondLabel, thirdLabel, fourthLabel };

            var learner = new BalancedBinaryClassificationRandomForestLearner(numberOfThreads: 1);

            Assert.Throws <NotSupportedException>(() => learner.Learn(trainDataObservations, trainDataLabels));
        }
Esempio n. 2
0
        public void BalancedBinaryClassificationRandomForestLearnerThrowsAtNanInLabels()
        {
            var trainDataObservations = new F64Matrix(
                new[]
            {
                1.0,
                2.0,
                3.0,
                4.0,
            },
                2,
                2);
            var trainDataLabels = new[] { 0.0, double.NaN };

            var learner = new BalancedBinaryClassificationRandomForestLearner(numberOfThreads: 1);

            Assert.Throws <ArgumentOutOfRangeException>(() => learner.Learn(trainDataObservations, trainDataLabels));
        }
Esempio n. 3
0
        public void BalancedBinaryClassificationRandomForestLearnerDoesNotThrowForCorrectLabel(double firstLabel, double secondLabel)
        {
            var trainDataObservations = new F64Matrix(
                new[]
            {
                1.0,
                2.0,
                3.0,
                4.0,
            },
                2,
                2);
            var trainDataLabels = new[] { firstLabel, secondLabel };

            var learner = new BalancedBinaryClassificationRandomForestLearner(numberOfThreads: 1);
            var model   = learner.Learn(trainDataObservations, trainDataLabels);

            model.Predict(trainDataObservations);
        }
Esempio n. 4
0
        public void BalancedBinaryClassificationRandomForestLearnerDoesNotThrowAtNanInObservations()
        {
            var trainDataObservations = new F64Matrix(
                new[]
            {
                1.0,
                2.0,
                double.NaN,
                double.NaN,
            },
                2,
                2);
            var trainDataLabels = new[] { 0.0, 1.0 };

            var learner = new BalancedBinaryClassificationRandomForestLearner(numberOfThreads: 1);
            var model   = learner.Learn(trainDataObservations, trainDataLabels);

            model.Predict(trainDataObservations);
        }