Example #1
0
        public static void TrainModelAt(BasicNetwork net, int gameNumber)
        {
            Console.WriteLine($"Training at {gameNumber}");
            string path     = Directory.GetCurrentDirectory() + @"\..\..\Model";
            string dataPath = Directory.GetCurrentDirectory() + @"\..\..\Data";

            //Check if data is already saved
            //if not null then parse
            OPSData data = OPSData.GetData(dataPath, "data");
            OPSGame game;

            //Check if not empty game and not already added to data
            if (data.GetGame(gameNumber) == null && !data.emptyGames.Contains(gameNumber))
            {
                game = Parser.ParseUrl(gameNumber);
                if (game != null)
                {
                    data.AddGame(game);
                }
                else
                {
                    data.AddEmptyGame(gameNumber);
                }
            }
            else
            {
                game = data.GetGame(gameNumber);
            }

            if (game == null)
            {
                Console.WriteLine(gameNumber + " was empty");
                return;
            }

            net.FeedForward(ToFloatArray(game.PlayerOPS));
            net.BackProp(ToFloatArray(game.TeamScores));

            net.SaveModel(path);
            data.SaveData(dataPath, "data");

            Console.WriteLine("Train sucessful!");
        }
Example #2
0
        public static void GetDataThrough(int minGameNumber, int maxGameNumber)
        {
            string dataPath = Directory.GetCurrentDirectory() + @"\..\..\Data";

            // If min and max is fliped
            if (minGameNumber > maxGameNumber)
            {
                int temp = maxGameNumber;
                maxGameNumber = minGameNumber;
                minGameNumber = temp;
            }

            Console.WriteLine("=========>Starting to collect data<=========");
            for (int i = maxGameNumber; i >= minGameNumber; i--)
            {
                Console.WriteLine($"Getting game data for {i}...");
                OPSData data = OPSData.GetData(dataPath, "data");

                // Check if there is no game data and is not empty game
                if (data.GetGame(i) == null && !data.emptyGames.Contains(i))
                {
                    // Parse Game and update it to the data
                    OPSGame game = Parser.ParseUrl(i);

                    if (game != null)
                    {
                        data.AddGame(game);
                        Console.WriteLine(" > Adding game stats.");
                    }
                    else
                    {
                        data.AddEmptyGame(i);
                        Console.WriteLine(" > Adding empty game");
                    }

                    data.SaveData(dataPath, "data");
                }
                Console.WriteLine($"Data updated for {i}...");
            }
        }
Example #3
0
        public static void TrainModelWithData(BasicNetwork net, int epochs)
        {
            string  path     = Directory.GetCurrentDirectory() + @"\..\..\Model";
            string  dataPath = Directory.GetCurrentDirectory() + @"\..\..\Data";
            OPSData data     = OPSData.GetData(dataPath, "data");
            var     games    = data.games;

            for (int j = 0; j < epochs; j++)
            {
                foreach (OPSGame value in games.Values)
                {
                    Console.WriteLine($"Training at {value.GameNumber}");
                    net.FeedForward(ToFloatArray(value.PlayerOPS));
                    net.BackProp(ToFloatArray(value.TeamScores));

                    net.SaveModel(path);
                    data.SaveData(dataPath, "data");

                    Console.WriteLine("Train sucessful!");
                }
            }
        }