Пример #1
0
 public static Tennis[] GetData()
 {
     return(new Tennis[]
     {
         Tennis.Make(Outlook.Sunny, Temperature.Hot, Humidity.High, false, false),
         Tennis.Make(Outlook.Sunny, Temperature.Hot, Humidity.High, true, false),
         Tennis.Make(Outlook.Overcast, Temperature.Hot, Humidity.High, false, true),
         Tennis.Make(Outlook.Rainy, Temperature.Mild, Humidity.High, false, true),
         Tennis.Make(Outlook.Rainy, Temperature.Cool, Humidity.Normal, false, true),
         Tennis.Make(Outlook.Rainy, Temperature.Cool, Humidity.Normal, true, false),
         Tennis.Make(Outlook.Overcast, Temperature.Cool, Humidity.Normal, true, true),
         Tennis.Make(Outlook.Sunny, Temperature.Mild, Humidity.High, false, false),
         Tennis.Make(Outlook.Sunny, Temperature.Cool, Humidity.Normal, false, true),
         Tennis.Make(Outlook.Rainy, Temperature.Mild, Humidity.Normal, false, true),
         Tennis.Make(Outlook.Sunny, Temperature.Mild, Humidity.Normal, true, true),
         Tennis.Make(Outlook.Overcast, Temperature.Mild, Humidity.High, true, true),
         Tennis.Make(Outlook.Overcast, Temperature.Hot, Humidity.Normal, false, true),
         Tennis.Make(Outlook.Rainy, Temperature.Mild, Humidity.High, true, false)
     });
 }
        public void Save_Node_Test()
        {
            Tennis t = new Tennis
            {
                Humidity = Humidity.Normal,
                Outlook = Outlook.Overcast,
                Temperature = Temperature.Cool,
                Windy = true
            };

            var model = (NeuralNetworkModel)BaseSupervised.Prediction<Tennis>(
                new NeuralNetworkGenerator(),
                Tennis.GetData(),
                t,
                p => p.Play
            );

            var node = model.Network.In[0].Out[0].Target;

            Serialize(node);
        }
        public void Save_Model_Test()
        {
            Tennis t = new Tennis
            {
                Humidity = Humidity.Normal,
                Outlook = Outlook.Overcast,
                Temperature = Temperature.Cool,
                Windy = true
            };

            var model = (NeuralNetworkModel)BaseSupervised.Prediction<Tennis>(
                new NeuralNetworkGenerator(),
                Tennis.GetData(),
                t,
                p => p.Play
            );

            Serialize(model);
            var model2 = Deserialize<NeuralNetworkModel>();

            Assert.Equal(model.Descriptor, model2.Descriptor);
            AreEqual(model.Network, model2.Network);
        }