Пример #1
0
        public void ArbitraryPrediction_Test_With_Enum_Label()
        {
            ArbitraryPrediction minimumPredictionValue = new ArbitraryPrediction
            {
                FirstTestFeature = 1.0m,
                SecondTestFeature = 10.0m,
                ThirdTestFeature = 1.2m
            };

            Prediction<ArbitraryPrediction>(
                new DecisionTreeGenerator(50),
                ArbitraryPrediction.GetData(),
                minimumPredictionValue,
                ap => ap.OutcomeLabel == ArbitraryPrediction.PredictionLabel.Minimum
            );

            ArbitraryPrediction maximumPredictionValue = new ArbitraryPrediction
            {
                FirstTestFeature = 1.0m,
                SecondTestFeature = 55.0m,
                ThirdTestFeature = 1.2m
            };

            Prediction<ArbitraryPrediction>(
                new DecisionTreeGenerator(50),
                ArbitraryPrediction.GetData(),
                maximumPredictionValue,
                ap => ap.OutcomeLabel == ArbitraryPrediction.PredictionLabel.Maximum
            );
        }
Пример #2
0
        public void ArbitraryPrediction_Test_With_Enum_Label()
        {
            var data = ArbitraryPrediction.GetData();
            var description = Descriptor.Create<ArbitraryPrediction>();
            var generator = new DecisionTreeGenerator(50);
            var model = generator.Generate(description, data);

            ArbitraryPrediction minimumPredictionValue = new ArbitraryPrediction
            {
                FirstTestFeature = 1.0m,
                SecondTestFeature = 10.0m,
                ThirdTestFeature = 1.2m
            };

            ArbitraryPrediction maximumPredictionValue = new ArbitraryPrediction
            {
                FirstTestFeature = 1.0m,
                SecondTestFeature = 55.0m,
                ThirdTestFeature = 1.2m
            };

            var expectedMinimum = model.Predict<ArbitraryPrediction>(minimumPredictionValue).OutcomeLabel;
            var expectedMaximum = model.Predict<ArbitraryPrediction>(maximumPredictionValue).OutcomeLabel;

            //The value should be minimum, however, maximum is returned
            Assert.AreEqual(ArbitraryPrediction.PredictionLabel.Minimum, expectedMinimum);
            //Maximum is returned as expected
            Assert.AreEqual(ArbitraryPrediction.PredictionLabel.Maximum, expectedMaximum);
        }
Пример #3
0
        public void ArbitraryPrediction_Test_With_Named_Iterator()
        {
            var data = ArbitraryPrediction.GetDataUsingNamedIterator();
            var description = Descriptor.Create<ArbitraryPrediction>();
            var generator = new DecisionTreeGenerator(50);
            var model = generator.Generate(description, data);

            ArbitraryPrediction minimumPredictionValue = new ArbitraryPrediction
            {
                FirstTestFeature = 1.0m,
                SecondTestFeature = 10.0m,
                ThirdTestFeature = 1.2m
            };

            ArbitraryPrediction maximumPredictionValue = new ArbitraryPrediction
            {
                FirstTestFeature = 1.0m,
                SecondTestFeature = 57.0m,
                ThirdTestFeature = 1.2m
            };

            var expectedMinimum = model.Predict<ArbitraryPrediction>(minimumPredictionValue).OutcomeLabel;
            var expectedMaximum = model.Predict<ArbitraryPrediction>(maximumPredictionValue).OutcomeLabel;

            Assert.AreEqual(ArbitraryPrediction.PredictionLabel.Minimum, expectedMinimum);
            Assert.AreEqual(ArbitraryPrediction.PredictionLabel.Maximum, expectedMaximum);
        }
Пример #4
0
        public void ArbitraryPrediction_Test_With_Feature_Value_Greater_Than_Trained_Instances()
        {
            ArbitraryPrediction predictionValue = new ArbitraryPrediction
            {
                FirstTestFeature = 1.0m,
                //This value is greater than any of the trained instances
                SecondTestFeature = 106.0m,
                ThirdTestFeature = 1.2m
            };

            Prediction<ArbitraryPrediction>(
                new DecisionTreeGenerator(50),
                ArbitraryPrediction.GetData(),
                predictionValue,
                ap => ap.OutcomeLabel == ArbitraryPrediction.PredictionLabel.Maximum
            );
        }
Пример #5
0
        public void ArbitraryPrediction_Test_With_Feature_Value_Greater_Than_Trained_Instances()
        {
            var data = ArbitraryPrediction.GetData();
            var description = Descriptor.Create<ArbitraryPrediction>();
            var generator = new DecisionTreeGenerator(50);
            var model = generator.Generate(description, data);

            ArbitraryPrediction predictionValue = new ArbitraryPrediction
            {
                FirstTestFeature = 1.0m,
                //This value is greater than any of the trained instances
                SecondTestFeature = 106.0m,
                ThirdTestFeature = 1.2m
            };

            var expectedValue = model.Predict<ArbitraryPrediction>(predictionValue).OutcomeLabel;
            Assert.AreEqual(ArbitraryPrediction.PredictionLabel.Maximum, expectedValue);
        }