Beispiel #1
0
        public static bool SuccessConditionLadderPrint(List <double> predicted, List <double> actual, string print)
        {
            var phLadder = Numbery.Denormalise(predicted[0], Util.MaxLadderPoints);
            var paLadder = Numbery.Denormalise(predicted[1], Util.MaxLadderPoints);

            var ahLadder = Numbery.Denormalise(actual[0], Util.MaxLadderPoints);
            var aaLadder = Numbery.Denormalise(actual[1], Util.MaxLadderPoints);

            if (print == "")
            {
                Console.WriteLine("[{0}, {1} Vs {2}, {3}] Suggested Bet: ${8:0.00}", phLadder, paLadder, ahLadder, aaLadder);
            }
            else if (!string.IsNullOrEmpty(print))
            {
                Filey.Save(string.Format("[{0}, {1} Vs {2}, {3}] Suggested Bet: ${8:0.00}", phLadder, paLadder, ahLadder, aaLadder), print);
            }

            if (phLadder > paLadder && ahLadder > aaLadder)
            {
                return(true);
            }
            if (phLadder < paLadder && ahLadder < aaLadder)
            {
                return(true);
            }
            if (phLadder == paLadder && ahLadder == aaLadder)
            {
                return(true);
            }
            return(false);
        }
Beispiel #2
0
        public static bool SuccessConditionGoalAndPoints(List <double> predicted, List <double> actual)
        {
            var phGoals  = Numbery.Denormalise(predicted[0], Util.MaxGoals);
            var phPoints = Numbery.Denormalise(predicted[1], Util.MaxPoints);
            var paGoals  = Numbery.Denormalise(predicted[2], Util.MaxGoals);
            var paPoints = Numbery.Denormalise(predicted[3], Util.MaxPoints);
            var phScore  = phGoals * 6 + phPoints;
            var paScore  = paGoals * 6 + paPoints;

            var ahGoals  = Numbery.Denormalise(actual[0], Util.MaxGoals);
            var ahPoints = Numbery.Denormalise(actual[1], Util.MaxPoints);
            var aaGoals  = Numbery.Denormalise(actual[2], Util.MaxGoals);
            var aaPoints = Numbery.Denormalise(actual[3], Util.MaxPoints);
            var ahScore  = ahGoals * 6 + ahPoints;
            var aaScore  = aaGoals * 6 + aaPoints;

            //Console.WriteLine("[{0}, {1} Vs {2}, {3}]", phScore, paScore, ahScore, aaScore);

            if (phScore > paScore && ahScore > aaScore)
            {
                return(true);
            }
            if (phScore < paScore && ahScore < aaScore)
            {
                return(true);
            }
            if (phScore == paScore && ahScore == aaScore)
            {
                return(true);
            }
            return(false);
        }
Beispiel #3
0
        public static double BetReturnGoalAndPoints(List <double> predicted, List <double> actual, double homeOdds, double awayOdds)
        {
            var phGoals  = Numbery.Denormalise(predicted[0], Util.MaxGoals);
            var phPoints = Numbery.Denormalise(predicted[1], Util.MaxPoints);
            var paGoals  = Numbery.Denormalise(predicted[2], Util.MaxGoals);
            var paPoints = Numbery.Denormalise(predicted[3], Util.MaxPoints);
            var phScore  = phGoals * 6 + phPoints;
            var paScore  = paGoals * 6 + paPoints;

            var ahGoals  = Numbery.Denormalise(actual[0], Util.MaxGoals);
            var ahPoints = Numbery.Denormalise(actual[1], Util.MaxPoints);
            var aaGoals  = Numbery.Denormalise(actual[2], Util.MaxGoals);
            var aaPoints = Numbery.Denormalise(actual[3], Util.MaxPoints);
            var ahScore  = ahGoals * 6 + ahPoints;
            var aaScore  = aaGoals * 6 + aaPoints;

            //Console.WriteLine("[{0}, {1} Vs {2}, {3}]", phScore, paScore, ahScore, aaScore);

            if (phScore > paScore && ahScore > aaScore)
            {
                return(homeOdds);
            }
            if (phScore < paScore && ahScore < aaScore)
            {
                return(awayOdds);
            }
            if (phScore == paScore && ahScore == aaScore)
            {
                return(1.00);
            }
            return(0.00);
        }
Beispiel #4
0
        public static bool SuccessConditionTotalPrint(List <double> predicted, List <double> actual, string print = "")
        {
            var phTotal = Numbery.Denormalise(predicted[0], Util.MaxScore);
            var paTotal = Numbery.Denormalise(predicted[1], Util.MaxScore);

            var ahTotal = Numbery.Denormalise(actual[0], Util.MaxScore);
            var aaTotal = Numbery.Denormalise(actual[1], Util.MaxScore);

            if (print == "")
            {
                Console.WriteLine("[{0}, {1} Vs {2}, {3}]", phTotal, paTotal, ahTotal, aaTotal);
            }
            else if (!string.IsNullOrEmpty(print))
            {
                Filey.Append(string.Format("[{0}, {1} Vs {2}, {3}]", phTotal, paTotal, ahTotal, aaTotal), print);
            }

            if (phTotal > paTotal && ahTotal > aaTotal)
            {
                return(true);
            }
            if (phTotal < paTotal && ahTotal < aaTotal)
            {
                return(true);
            }
            if (phTotal == paTotal && ahTotal == aaTotal)
            {
                return(true);
            }
            return(false);
        }
Beispiel #5
0
        public void TestNormaliser_For_NormaliseDenormaliseAsymptotic()
        {
            var input      = 10.0;
            var normalised = Numbery.Normalise(input, 5, 55, 25, 775, Numbery.NormalisationMethod.Asymptotic);
            var output     = Numbery.Denormalise(normalised, 25, 775, 5, 55, Numbery.NormalisationMethod.Asymptotic);

            Assert.IsTrue(output < input + 0.000001);
            Assert.IsTrue(output > input - 0.000001);
        }
Beispiel #6
0
        public List <Match> Predict(int year, int round, bool print)
        {
            Func <double, double> rule = (m => m > 27.0 ? 15.00 : 0.00);

            var results = new List <Match>();
            var rounds  = League.GetRounds(0, 0, year, round).Where(x => x.Matches.Count > 0).ToList();

            foreach (var m in rounds.Where(r => (r.Year == year && r.Number == round)).SelectMany(r => r.Matches))
            {
                var history =
                    rounds.Where(r => !r.Matches.Any(rm => rm.Date >= m.Date)).SelectMany(r => r.Matches).ToList();
                var test = BuildInputs(history, m);

                var result = Net.Run(test);
                results.Add(new Match(
                                m.Home,
                                new Score(0, 0),
                                new Score(0, 0),
                                new Score(0, 0),
                                new Score(
                                    Numbery.Denormalise(result[0], Util.MaxGoals), //, Numbery.NormalisationMethod.Asymptotic),
                                    Numbery.Denormalise(result[1], Util.MaxPoints) //, Numbery.NormalisationMethod.Asymptotic)
                                    ),
                                m.Away,
                                new Score(0, 0),
                                new Score(0, 0),
                                new Score(0, 0),
                                new Score(
                                    Numbery.Denormalise(result[2], Util.MaxGoals), //, Numbery.NormalisationMethod.Asymptotic),
                                    Numbery.Denormalise(result[3], Util.MaxPoints) //, Numbery.NormalisationMethod.Asymptotic)
                                    ),
                                m.Ground, m.Date));

                var margin = Math.Abs(results.Last().HomeScore().Total() - results.Last().AwayScore().Total());
                var wager  = rule(margin);

                if (print)
                {
                    Console.WriteLine("{0,9} Vs {1, 9}: {2}, Bet: ${3:0.00}",
                                      m.Home.Mascot, m.Away.Mascot,
                                      Printlayer(new[]
                    {
                        results.Last().HomeScore().Goals,
                        results.Last().HomeScore().Points,
                        results.Last().HomeScore().Total(),
                        results.Last().AwayScore().Goals,
                        results.Last().AwayScore().Points,
                        results.Last().AwayScore().Total()
                    }), wager);
                }
            }
            return(results);
        }
Beispiel #7
0
        public static List <double> Deconvert(List <double> input)
        {
            var hGoals  = Numbery.Denormalise(input[0], Util.MaxGoals);
            var hPoints = Numbery.Denormalise(input[1], Util.MaxPoints);
            var aGoals  = Numbery.Denormalise(input[2], Util.MaxGoals);
            var aPoints = Numbery.Denormalise(input[3], Util.MaxPoints);

            return(new List <double>()
            {
                hGoals, hPoints, aGoals, aPoints
            });
        }
Beispiel #8
0
        public static bool SuccessConditionLadderGoalsAndPointsPrint(List <double> predicted, List <double> actual, string print)
        {
            Func <double, double> rule = (m => m > 27.0 ? 15.00 : 0.00);

            var phLadder = Numbery.Denormalise(predicted[0], Util.MaxLadderPoints);
            var paLadder = Numbery.Denormalise(predicted[1], Util.MaxLadderPoints);
            var phGoals  = Numbery.Denormalise(predicted[2], Util.MaxGoals);
            var phPoints = Numbery.Denormalise(predicted[3], Util.MaxPoints);
            var paGoals  = Numbery.Denormalise(predicted[4], Util.MaxGoals);
            var paPoints = Numbery.Denormalise(predicted[5], Util.MaxPoints);
            var phScore  = phGoals * 6 + phPoints;
            var paScore  = paGoals * 6 + paPoints;

            var ahLadder = Numbery.Denormalise(actual[0], Util.MaxLadderPoints);
            var aaLadder = Numbery.Denormalise(actual[1], Util.MaxLadderPoints);
            var ahGoals  = Numbery.Denormalise(actual[2], Util.MaxGoals);
            var ahPoints = Numbery.Denormalise(actual[3], Util.MaxPoints);
            var aaGoals  = Numbery.Denormalise(actual[4], Util.MaxGoals);
            var aaPoints = Numbery.Denormalise(actual[5], Util.MaxPoints);
            var ahScore  = ahGoals * 6 + ahPoints;
            var aaScore  = aaGoals * 6 + aaPoints;

            var margin = Math.Abs(phScore - ahScore);
            var wager  = rule(margin);

            if (print == "")
            {
                Console.WriteLine("[{0}: {1}, {2}: {3} Vs {4}: {5}, {6}: {7}] Suggested Bet: ${8:0.00}", phLadder, phScore, paLadder, paScore, ahLadder, ahScore, aaLadder, aaScore, wager);
            }
            else if (!string.IsNullOrEmpty(print))
            {
                Filey.Save(string.Format("[{0}: {1}, {2}: {3} Vs {4}: {5}, {6}: {7}] Suggested Bet: ${8:0.00}", phLadder, phScore, paLadder, paScore, ahLadder, ahScore, aaLadder, aaScore, wager), print);
            }

            if (phScore > paScore && ahScore > aaScore)
            {
                return(true);
            }
            if (phScore < paScore && ahScore < aaScore)
            {
                return(true);
            }
            if (phScore == paScore && ahScore == aaScore)
            {
                return(true);
            }
            return(false);
        }
Beispiel #9
0
        /*
         * public void Test(Data data)
         * {
         *  var successes = 0;
         *  var stopwatch = new Stopwatch();
         *  stopwatch.Start();
         *
         *  NetworkActor.Facade.SetData(data);
         *  var subset = NetworkActor.Facade.GetData();
         *
         *  for(var i = 0; i < subset.Inputs().Count; i++)
         *  {
         *      var input = subset.DataPoints[i].Inputs;
         *      var output = NetworkActor.Network.Run(input);
         *      var wager = CalculateWager(output);
         *      Money -= wager;
         *      var success = subset.SuccessCondition(output, subset.DataPoints[i].Outputs, null);
         *      if (success)
         *      {
         *          successes++;
         *          var composite = (Tuple<DateTime, string>)subset.DataPoints[i].Reference;
         *          //Attempting to convert from "DataPoint Match reference to tuple reference
         *          //Realised this wasn't used and commented out for now
         *
         *          var homescore = (Match.FindMatchByTuple(, ).HomeScore().Total();
         *          var awayscore = ((Match) subset.DataPoints[i].Reference).AwayScore().Total();
         *          var odds = 0.0;
         *          if(homescore > awayscore)
         *              odds = ((Match)subset.DataPoints[i].Reference).HomeOdds;
         *          if (homescore < awayscore)
         *              odds = ((Match)subset.DataPoints[i].Reference).AwayOdds;
         *          Money += wager*odds;
         *      }
         *  }
         *  //Console.WriteLine("successes = " + (double)successes / (double)subset.Inputs().Count);
         *  stopwatch.Stop();
         *  TimeToTest = stopwatch.ElapsedMilliseconds;
         * }*/

        private double CalculateWager(List <double> output)
        {
            var wager    = 0.0;
            var phGoals  = Numbery.Denormalise(output[0], Util.MaxGoals);
            var phPoints = Numbery.Denormalise(output[1], Util.MaxPoints);
            var paGoals  = Numbery.Denormalise(output[2], Util.MaxGoals);
            var paPoints = Numbery.Denormalise(output[3], Util.MaxPoints);
            var phScore  = phGoals * 6 + phPoints;
            var paScore  = paGoals * 6 + paPoints;
            var margin   = Math.Abs(phScore - paScore);
            var ordered  = Rules.OrderByDescending(x => x.Priority).ToList();

            foreach (var rule in ordered)
            {
                wager = rule.Scenario(margin);
            }
            return(wager);
        }
Beispiel #10
0
        public List <PredictedMatch> PredictWinners(int year, int round, bool isFinal, DataInterpretation interpretation = null)
        {
            var predictions = new List <PredictedMatch>();
            var rounds      = League.GetRounds(0, 0, year, round).Where(x => x.Matches.Count > 0).ToList();

            foreach (var m in rounds.Where(r => r.Year == year && r.Number == round && r.IsFinal == isFinal).SelectMany(r => r.Matches))
            {
                //TODO: Are we ordering in the right direction?
                var history =
                    rounds.Where(r => !r.Matches.Any(rm => rm.Date >= m.Date)).SelectMany(r => r.Matches).OrderBy(h => h.Date).ToList();

                var test = BuildInputs(history, m, interpretation);

                var result = Net.Run(test);

                predictions.Add(new PredictedMatch(m.Home, m.Away, m.Ground, m.Date, Numbery.Denormalise(result[0], Util.MaxScore), Numbery.Denormalise(result[1], Util.MaxScore), round));
            }
            return(predictions);
        }
Beispiel #11
0
        public static bool SuccessConditionScore(List <double> predicted, List <double> actual)
        {
            var phScore = Numbery.Denormalise(predicted[0], Util.MaxScore);
            var paScore = Numbery.Denormalise(predicted[1], Util.MaxScore);

            var ahScore = Numbery.Denormalise(actual[0], Util.MaxScore);
            var aaScore = Numbery.Denormalise(actual[1], Util.MaxScore);

            if (phScore > paScore && ahScore > aaScore)
            {
                return(true);
            }
            if (phScore < paScore && ahScore < aaScore)
            {
                return(true);
            }
            if (phScore == paScore && ahScore == aaScore)
            {
                return(true);
            }
            return(false);
        }
Beispiel #12
0
        public static bool SuccessConditionTotalAsymptotic(List <double> predicted, List <double> actual, string legacy)
        {
            var phTotal = Numbery.Denormalise(predicted[0], Util.MaxScore, Numbery.NormalisationMethod.Asymptotic);
            var paTotal = Numbery.Denormalise(predicted[1], Util.MaxScore, Numbery.NormalisationMethod.Asymptotic);

            var ahTotal = Numbery.Denormalise(actual[0], Util.MaxScore);
            var aaTotal = Numbery.Denormalise(actual[1], Util.MaxScore);


            if (phTotal > paTotal && ahTotal > aaTotal)
            {
                return(true);
            }
            if (phTotal < paTotal && ahTotal < aaTotal)
            {
                return(true);
            }
            if (phTotal == paTotal && ahTotal == aaTotal)
            {
                return(true);
            }
            return(false);
        }
Beispiel #13
0
        public static bool SuccessConditionTotal(List <double> predicted, List <double> actual)
        {
            var phTotal = Numbery.Denormalise(predicted[0], Util.MaxScore);
            var paTotal = Numbery.Denormalise(predicted[1], Util.MaxScore);

            var ahTotal = Numbery.Denormalise(actual[0], Util.MaxScore);
            var aaTotal = Numbery.Denormalise(actual[1], Util.MaxScore);

            Filey.Append(string.Format("[{0}, {1} Vs {2}, {3}]", phTotal, paTotal, ahTotal, aaTotal), @"C:\Users\Jack\Desktop\ANN Optimizer results.txt");

            if (phTotal > paTotal && ahTotal > aaTotal)
            {
                return(true);
            }
            if (phTotal < paTotal && ahTotal < aaTotal)
            {
                return(true);
            }
            if (phTotal == paTotal && ahTotal == aaTotal)
            {
                return(true);
            }
            return(false);
        }
Beispiel #14
0
        public void TestDenormaliser_For_DenormaliseGradiated()
        {
            var output = Numbery.Denormalise(0.75, 200, Numbery.NormalisationMethod.Gradiated);

            Assert.AreEqual(150, output);
        }
Beispiel #15
0
        public void TestNormaliser_For_Deormalise_Offset()
        {
            var result = Numbery.Denormalise(3, 2, 12, 10, 110, Numbery.NormalisationMethod.Normal);

            Assert.AreEqual(20, result);
        }
Beispiel #16
0
        public void TestNormaliser_For_Deormalise()
        {
            var result = Numbery.Denormalise(0.75, 200, Numbery.NormalisationMethod.Normal);

            Assert.AreEqual(150, result);
        }
Beispiel #17
0
        public void TestDenormaliser_For_DenormaliseAsymptotic()
        {
            var output = Numbery.Denormalise(0.080247933884297518, 100, Numbery.NormalisationMethod.Asymptotic);

            Assert.IsTrue(output > 35.9 && output < 36.1);
        }