SetHint() 공개 메소드

Sets a hint.
public SetHint ( object o ) : void
o object The object to process.
리턴 void
예제 #1
0
 public void Predict()
 {
     Tennis[] data = Tennis.GetData();
     Descriptor descriptor = Descriptor.Create<Tennis>();
     var generator = new DecisionTreeGenerator(descriptor);
     generator.SetHint(0.5d);
     LearningModel model = Learner.Learn(data, 0.8, 1000, generator);
     var input = new Tennis
     {
         Outlook = Outlook.Overcast,
         Temperature = 20,
         Windy = false
     };
     Tennis predict = model.Model.Predict(input);
     Console.WriteLine(predict.Play);
     Console.WriteLine(model);
 }
예제 #2
0
        static void Main(string[] args)
        {
            var data = Tennis.GetData();
            var descriptor = Descriptor.Create<Tennis>();
            var treeGenerator = new DecisionTreeGenerator(descriptor);
            treeGenerator.SetHint(false);
            var model = Learner.Learn(data, 0.80, 1000, treeGenerator);
            System.Console.WriteLine(model);
            System.Console.ReadKey();

            var t = new Tennis
            {
                Outlook = Outlook.Overcast,
                Temperature = Temperature.Low,
                Windy = true
            };
            var result = model.Model.Predict(t);
            System.Console.WriteLine(result.Play);
        }
예제 #3
0
        /// <summary>
        /// Do the <see cref="SimpleNumlWorkflow" /> using a <c>DecisionTree</c> generator/model.
        /// </summary>
        static void DoSimple_DecisionTree(Outlook outlook = Outlook.Sunny, double tempF = 15.0d, bool windy = true,
            int depth = 5, int width = 2, int repeat = 5000)
        {
            SimpleNumlWorkflow.SimpleNumlWorkflowImpl(
                getData: () => SampleData_ComplexType.GetTennisData_ComplexType(predetermined: false),

                getDescriptor: () => Descriptor.Create<Tennis_Complex>(),

                getGenerator: (descriptor) =>
                {
                    var generator = new DecisionTreeGenerator(descriptor)
                    {
                        Depth = depth,
                        Width = width
                    };
                    generator.SetHint(false);
                    return generator;
                },

                getToPredict: () =>
                {
                    return new Tennis_Complex()
                    {
                        WeatherConditions = new WeatherConditions()
                        {
                            Outlook = outlook,
                            Temperature = tempF,
                            Windy = windy,
                        }
                    };
                },

                getPredictionDesc: (t) => "Play: " + t.Play,

                trainingPercentage: 0.8d,

                repeat: repeat
                );
        }
예제 #4
0
        public static void Go()
        {
            // Start with our data
            Tennis[] data = SharedData.GetTennisData();

            // Create the corresponding descriptor
            var descriptor = Descriptor.Create<Tennis>();

            // Choose our generator
            var generator = new DecisionTreeGenerator(descriptor);
            generator.SetHint(false);

            Console.WriteLine($"Using the {generator.GetType().Name}\n");

            // Create the model by learning from the data using the generator
            LearningModel learningModel = Learner.Learn(data, 0.80, 1000, generator);

            Console.WriteLine(learningModel);

            // Now we could predict using the learning info's Model.
            var toPredict = new Tennis()
            {
                Outlook = Outlook.Rainy,
                Temperature = Temperature.Low,
                Windy = true,
                // Play = ? - This is what we will predict
            };

            var prediction = learningModel.Model.Predict(toPredict);

            // And we're spent...
            Console.WriteLine($"ToPredict: {toPredict}");
            Console.WriteLine($"Prediction: Play = {prediction.Play}\n");

            Console.WriteLine("Press any key...\n");
            Console.ReadKey();
        }