Ejemplo n.º 1
0
        /// <summary>
        /// Do the <c>SimpleNumlWorkflow</c> using a <c>Neural Network</c> generator/model.
        /// </summary>
        /// <param name="simpleData">If true, uses a preset small sample data set; else generates a larger, pseudo-random one.</param>
        /// <param name="maxIterations"></param>
        /// <param name="learningRate"></param>
        static void DoSimple_NeuralNetwork(bool simpleData     = true, int maxIterations = 10000,
                                           double learningRate = 0.9d)
        {
            SimpleNumlWorkflowImpl(
                getData: () => SampleData.GetTennisData(simpleData),

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

                // This is where we choose the actual algorithm
                getGenerator: (descriptor) =>
            {
                var generator = new numl.Supervised.NeuralNetwork.NeuralNetworkGenerator()
                {
                    Descriptor    = descriptor,
                    MaxIterations = maxIterations,
                    LearningRate  = learningRate
                };
                return(generator);
            },

                getToPredict: () =>
            {
                return(new Tennis()
                {
                    Outlook = Outlook.Rainy,
                    Temperature = Temperature.Low,
                    Windy = true
                });
            },

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

                trainingPercentage: 0.8d,

                repeat: 50
                );
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Do the <see cref="SimpleNumlWorkflow" /> using a <c>Neural Network</c> generator/model.
        /// </summary>
        static void DoSimple_NeuralNetwork(Outlook outlook = Outlook.Sunny, double tempF = 15.0d, bool windy = true,
            int maxIterations = 10000, double learningRate = 0.9d, int repeat = 500)
        {
            SimpleNumlWorkflow.SimpleNumlWorkflowImpl(
                getData: () => SampleData_ComplexType.GetTennisData_ComplexType(predetermined: false),

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

                // This is where we choose the actual algorithm
                getGenerator: (descriptor) =>
                {
                    var generator = new numl.Supervised.NeuralNetwork.NeuralNetworkGenerator()
                    {
                        Descriptor = descriptor,
                        MaxIterations = maxIterations,
                        LearningRate = learningRate
                    };
                    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
                );
        }