Exemple #1
0
        public static List <OddsCSVMatch> LoadMatchOddsList()
        {
            var rows     = Filey.LoadLines("HistoricalOdds.csv");
            var oddsList = rows.Skip(1).Select(CreateFromCsv).ToList();

            return(oddsList);
        }
Exemple #2
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);
        }
Exemple #3
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);
        }
Exemple #4
0
        public TwitterHelper()
        {
            //TODO: should pull this from a Keystore
            var file = Filey.Load(@"C:\Users\Jack\Documents\Visual Studio 2012\Projects\AFLTipper\keys.keys").Split('\n');

            APIKey            = file [0].Replace("API key: ", "").Replace("\r", "");
            APISecretKey      = file[1].Replace("API secret key: ", "").Replace("\r", "");
            BearerToken       = file[2].Replace("Bearer token: ", "").Replace("\r", "");
            AccessToken       = file[3].Replace("Access token: ", "").Replace("\r", "");
            AccessTokenSecret = file[4].Replace("Access token secret: ", "").Replace("\r", "");
        }
Exemple #5
0
        public void FindMe_Should_FindDetailsInSafewayHTML()
        {
            //Arrange
            string path = AppDomain.CurrentDomain.BaseDirectory;
            var    html = Filey.Load(path + @"\..\..\TestDataSafewayHTML.txt");
            //HtmlySearchInformation searchInformation = new HtmlySearchInformation();
            //Act
            var cost = Htmly.FindCostIn(html, "almonds");

            //Assert
            Assert.IsTrue(cost.Length > 0);
        }
Exemple #6
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);
        }
Exemple #7
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);
        }
Exemple #8
0
        public override void Train(Network network, List <List <double> > inputs, List <List <double> > targets)
        {
            network.Epochs = 0;
            var          minima         = 0;
            double       minError       = -1;
            double       maxError       = -1;
            double       prevError      = -1;
            const double cycleLength    = 100;
            double       cullPopulation = 50;
            var          log            = new List <List <double> >();

            do
            {
                network.Error = network.TrainEpoch(inputs, targets) / inputs.Count;
                network.Epochs++;
                minima++;

                if (network.Error < minError || minError < 0)
                {
                    minima   = 0;
                    minError = network.Error;
                    //Network.Save(network); //TODO: reinstate using mongodb
                }

                if (network.Error > maxError)
                {
                    maxError = network.Error;
                }

                if (network.Error > prevError)
                {
                    AdjustLearningRateDown(network);
                }
                prevError = network.Error;
                log.Add(new List <double>()
                {
                    network.Epochs, minima, network.Error, minError, maxError
                });

                //Cull outliers
                var largestError     = 0;
                var populationErrors = new Dictionary <int, double>();
                var temp             = "Number,Error\n";
                if (network.Epochs % cycleLength == 0)
                {
                    //for each of the training cases
                    for (var i = 0; i < inputs.Count; i++)
                    {
                        //get the output List for the given input List
                        var outputs = network.Run(inputs[i]);
                        var error   = outputs.Select((t, j) => Math.Abs(targets[i][j] - t)).Sum();
                        populationErrors.Add(i, error);
                    }

                    temp = populationErrors.Aggregate(temp, (current, p) => current + ("" + p.Key + "," + p.Value + "\n"));
                    Filey.Save(temp, "tamp_ANNOutput.txt");
                    var boundary    = LocatePercentileError(0.995, populationErrors.Select(e => e.Value).ToList());
                    var cullInputs  = populationErrors.Where(p => p.Value > boundary).Select(e => inputs[e.Key]);
                    var cullTargets = populationErrors.Where(p => p.Value > boundary).Select(e => targets[e.Key]);
                    foreach (var i in cullInputs)
                    {
                        inputs.Remove(i);
                    }
                    foreach (var t in cullTargets)
                    {
                        targets.Remove(t);
                    }
                }
            } while (minima < network.MaxMinima && network.Epochs < network.MaxEpochs);

            network = Network.Load(network.Directory + network.Id + ".ann");
            Filey.Save(log, "Network/Algorithm/Log.txt");
            var rankings = network.RankInputs();

            Filey.Save(rankings, "Network/Algorithm/Rankings.txt");
        }