Exemplo n.º 1
0
        public ActionResult RunModel(string connectionId)
        {
            try
            {
                if (!string.IsNullOrEmpty(connectionId))
                {
                    //Get the raw data
                    Functions.SendProgress(connectionId, "Loading Data.", false);
                    var rawData = NetworkFactory.GetInputData();
                    var ideals  = NetworkFactory.GetIdealValues();
                    Functions.SendProgress(connectionId, "Loading Complete.", false);

                    Functions.SendProgress(connectionId, "Formatting Data.", false);
                    //Format the data so it can be used in a neural network - all columns will have a value between 0-1 (floating point)
                    var formattedData = NetworkFactory.FormatInputValues(rawData);
                    Functions.SendProgress(connectionId, "Formatting Complete.", false);

                    Functions.SendProgress(connectionId, "Creating Network.", false);
                    //Create Network
                    var network = NetworkFactory.CreateNetwork(formattedData, ideals, 40);
                    Functions.SendProgress(connectionId, "Network Created.", false);

                    Functions.SendProgress(connectionId, "Training Network.", false);
                    //Train network
                    var trainedNetwork = NetworkFactory.TrainNetwork(network, formattedData, ideals, 20000,
                                                                     0.001, connectionId, Functions.SendProgress);
                    Functions.SendProgress(connectionId, "Training Complete.", false);

                    Functions.SendProgress(connectionId, "Testing Network.", false);
                    //Finally test the network
                    NetworkFactory.TestNetwork(network, formattedData, ideals, connectionId, Functions.SendProgress);
                    Functions.SendProgress(connectionId, "Testing Complete.", false);

                    //Return status
                    network        = null;
                    trainedNetwork = null;
                    return(new JsonResult()
                    {
                        Data = new { Status = "Success", Message = "Complete" },
                        JsonRequestBehavior = JsonRequestBehavior.DenyGet
                    });
                }
                throw new Exception("Empty Connection ID");
            }
            catch (Exception ex)
            {
                return(new JsonResult()
                {
                    Data = new { Status = "Failure", Message = "Error running model" },
                    JsonRequestBehavior = JsonRequestBehavior.DenyGet
                });
            }
        }
Exemplo n.º 2
0
        public static void RunANN()
        {
            //Get the raw data
            var rawData = NetworkFactory.GetInputData();
            var ideals  = NetworkFactory.GetIdealValues();
            //Format the data so it can be used in a neural network - all columns will have a value between 0-1 (floating point)
            var formattedData = NetworkFactory.FormatInputValues(rawData);
            //Create Network
            var network = NetworkFactory.CreateNetwork(formattedData, ideals, 40);
            //Train network
            var trainedNetwork = NetworkFactory.TrainNetwork(network, formattedData, ideals, 20000, 0.001, string.Empty, OutputEpoch);

            //Finally test the network
            NetworkFactory.TestNetwork(network, formattedData, ideals, string.Empty);
        }