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);
        }
Esempio n. 3
0
        public static AttributesMatch GetAttributeMatch(sakilaEntities4 db, competitionmatch match)
        {
            var attributesDict     = SecondaryStatsCalculator.BuildAttributesDictionary(match.CompetitionID, db, 50, match.MatchDate);
            var homeTeamAttributes = Helper.GetTeamAttributeFromDict((int)match.HomeTeamID, attributesDict);
            var awayTeamAttributes = Helper.GetTeamAttributeFromDict((int)match.AwayTeamID, attributesDict);
            List <DataObjects.AttributeType> winnerAttributes = null;

            if (match.WinnerTeamID == match.HomeTeamID)
            {
                winnerAttributes = homeTeamAttributes;
            }
            else if (match.WinnerTeamID == match.AwayTeamID)
            {
                winnerAttributes = awayTeamAttributes;
            }

            return(new AttributesMatch
            {
                HomeAttributes = homeTeamAttributes,
                AwayAttributes = awayTeamAttributes,
                WinnerAttributes = winnerAttributes
            });
        }