Beispiel #1
0
        public static void PrintTestFile(int daysToGet, int competitionId)
        {
            StatisticLine.initDict();
            var matchesToWrite = new List <string>();
            var linesToWrite   = new List <string>();

            linesToWrite.Add(StatisticLine.PrintCsvTestAttrs());
            var matches = PremierLeagueMainProject.GetNextMatches(daysToGet);

            foreach (var match in matches)
            {
                var matchLine = match.HomeTeam + " VS. " + match.AwayTeam;
                Console.WriteLine(match.HomeTeam + " VS. " + match.AwayTeam);
                matchesToWrite.Add(match.HomeTeam + " VS. " + match.AwayTeam);
                var sl = new StatisticLine();
                sl.init(match.HomeTeam, match.AwayTeam, match.Date, competitionId);
                sl.BuildTestLine();
                var line = matchLine + "," + sl.Print();
                if (line != null)
                {
                    linesToWrite.Add(line);
                }
            }

            File.WriteAllLines(@"C:\Users\user\Desktop\DataProjects\PredictionsModel\test.csv", linesToWrite);
            //File.WriteAllLines(@"C:\Users\user\Desktop\DataProjects\testlines.csv", matchesToWrite);
        }
        public static void PrintReportForNextDays(int daysToGet)
        {
            var matches              = PremierLeagueMainProject.GetNextMatches(daysToGet);
            var combinedLetterDict   = LettersSequenceCalculator.GetCombinedLettersDictionary();
            var attributeDict        = SecondaryStatsCalculator.BuildAttributesDictionary(3);
            var attributeClashingMap = MainCalculator.BuildAttributeMatchMap();

            foreach (var match in matches)
            {
                Console.WriteLine(match.HomeTeam + " Vs. " + match.AwayTeam);
                CreateMatchReport(combinedLetterDict, attributeDict, attributeClashingMap, match.HomeTeam, match.AwayTeam, 3);
            }
        }
        public static void PrintReportForNextDaysNewVersion(int daysToGet, int competitionId, bool withAttr = false)
        {
            Console.WriteLine($"Started: {DateTime.Now.Hour}:{DateTime.Now.Minute}");
            var matches = PremierLeagueMainProject.GetNextMatches(daysToGet);

            Console.WriteLine($"Got {matches.Count} new matches");
            var combinedLetterDict   = LettersSequenceCalculator.GetCombinedLettersDictionary();
            var attributeClashingMap = new List <MainCalculator.AttributesMatch>();
            var attributeDict        = new Dictionary <int, List <DataObjects.AttributeType> >();

            if (withAttr)
            {
                Console.WriteLine("Starting building attributes dictionary");
                attributeDict = SecondaryStatsCalculator.BuildAttributesDictionary(competitionId);
                Console.WriteLine("Finished building attributes dictionary");
                attributeClashingMap = MainCalculator.BuildAttributeMatchMap();
                Console.WriteLine($"Ended build: {DateTime.Now.Hour}:{DateTime.Now.Minute}");
            }

            var recs     = new List <MainCalculator.Recommendation>();
            var recsPath = @"C:\Users\user\Desktop\DataProjects\2018\RecommendationsFile.tsv";

            foreach (var match in matches)
            {
                var path = @"C:\Users\user\Desktop\DataProjects\2018\" + match.HomeTeam + "VS" + match.AwayTeam + ".tsv";
                Console.WriteLine(match.HomeTeam + " Vs. " + match.AwayTeam);
                var reportObj = new ReportObject();
                reportObj.Init(combinedLetterDict, attributeDict, attributeClashingMap, competitionId);
                reportObj.Build(match.HomeTeam, match.AwayTeam);

                reportObj.CalculateExpectedWinnerByStrength();
                reportObj.CalculateExpectedWinnerByLetters();
                //reportObj.CalculateAttributesExpectedWinner();

                reportObj.FindRecommendations();
                recs.AddRange(reportObj.MatchRecommendations);

                var linesToWrite = reportObj.GetLinesToWrite();
                File.WriteAllLines(path, linesToWrite);
            }

            var recsToWrite = recs.Where(x => x.Result != null)
                              .Where(x => x.Confidence >= 60m)
                              .OrderByDescending(x => x.Confidence)
                              .Select(x => $"{x.HomeTeam} VS. {x.AwayTeam} ({x.Type}): {x.Result} ({x.Confidence}%) (Ratio: {Math.Round(100/x.Confidence, 2)})");

            File.WriteAllLines(recsPath, recsToWrite);
        }