Esempio n. 1
0
        public static void RunPredictions(WriteToCMDLine write)
        {
            OpenFileDialog ofd = new OpenFileDialog()
            {
                FileName = "Select a binary file",
                Filter   = "BIN files (*.bin)|*.bin",
                Title    = "Open bin file"
            };

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                int    runs     = 0;
                double er       = 0;
                var    filepath = ofd.FileName;
                var    dir      = Path.GetDirectoryName(filepath);
                var    Files    = Directory.GetFiles(dir);
                Random random   = new Random();
                for (int i = 0; i < 1000; i++)
                {
                    string f = Files[random.Next(Files.Count())];
                    try
                    {
                        Sample s        = f.ReadFromBinaryFile <Sample>();
                        string datatype = s.Datatype;
                        var    error    = MasterformatNetwork.Propogate(s, write, true);
                        //var error = new MasterformatNetwork(s).PropogateSingle(s, write, true);
                        if (error > 0)
                        {
                            runs++;
                            er += error;

                            write("Total Error : " + er);
                            write("Total Runs : " + runs);
                            write("Error : " + er / runs);
                            write("");
                        }
                        else
                        {
                            write("");
                            write("error was 0");
                            write("");
                        }
                    }
                    catch (Exception e) { e.OutputError(); }
                }
            }
        }
Esempio n. 2
0
 public static void TestPredictions(string phrase, string dt, WriteToCMDLine write)
 {
     if (Enum.GetNames(typeof(Datatype)).Any(x => dt == x))
     {
         Datatype dtype = (Datatype)Enum.Parse(typeof(Datatype), dt);
         switch (dtype)
         {
         default:
         case Datatype.Masterformat:
             var outputs = MasterformatNetwork.Predict(phrase, write);
             var output  = outputs.ToList().IndexOf(outputs.Max());
             try { outputs.WriteArray("Values", write); } catch (Exception e) { e.OutputError(); }
             write(phrase + " : Division Number : " + output.ToString());
             break;
         }
     }
 }