public NeuralPredictionModel(MiniNetwork n) //New Random Prediction Model
        {
            shows     = n.shows;
            isMutated = false;

            InputCount  = n.factors.Count + 2;
            NeuronCount = Convert.ToInt32(Math.Round(InputCount * 2.0 / 3.0 + 1, 0));

            FirstLayer  = new Neuron[NeuronCount];
            SecondLayer = new Neuron[NeuronCount];

            for (int i = 0; i < NeuronCount; i++)
            {
                FirstLayer[i]  = new Neuron(InputCount);
                SecondLayer[i] = new Neuron(NeuronCount);
            }

            Output = new Neuron(NeuronCount);

            Random r = new Random();

            mutationrate      = r.NextDouble();
            mutationintensity = r.NextDouble();
            neuralintensity   = r.NextDouble();
        }
Ejemplo n.º 2
0
        public PredictionContainer(Show s, MiniNetwork n, double average, bool FromNetwork = false, bool?year = null, bool final = false)
        {
            network    = n;
            UseNetwork = FromNetwork;
            var model = network.model;

            show = s;
            odds = s.PredictedOdds;
            var threshold = model.GetThreshold(s);

            if (s.year == NetworkDatabase.MaxYear)
            {
                threshold = Math.Pow(threshold, s.network.Adjustment);
            }

            targetrating    = model.GetTargetRating(s.year, threshold);
            ShowDetails     = false;
            IsShowPage      = false;
            IsLoaded        = false;
            _networkaverage = average;
            finalodds       = s.Renewed || s.Canceled ? s.FinalPrediction : s.PredictedOdds;
            NetworkDatabase.CurrentYearUpdated += NetworkDatabase_CurrentYearUpdated;
            DisplayYear = year;
            UseFinal    = final;
        }
Ejemplo n.º 3
0
        public void Filter(bool UseNetwork = true, bool UseFinal = false, bool UseYear = false, List <Year> years = null)
        {
            Predictions.Clear();
            FilteredShows.Clear();
            var year = NetworkDatabase.YearList[NetworkDatabase.CurrentYear];
            //var Adjustments = model.GetAdjustments(true);
            var average = model.GetNetworkRatingsThreshold(year);

            if (!UseYear)
            {
                years = new List <Year>()
                {
                    new Year(NetworkDatabase.YearList[NetworkDatabase.CurrentYear])
                }
            }
            ;

            shows.Where(x => years.Select(y => y.year).Contains(x.year)).ToList().ForEach(x => FilteredShows.Add(x));

            if (UseYear || !UseNetwork)
            {
                var p = new ListOfPredictions {
                    Category = "Predictions"
                };

                foreach (Show s in FilteredShows)
                {
                    p.Add(new PredictionContainer(s, this, average, false, UseYear, UseFinal));
                }

                if (Predictions.Count > 0)
                {
                    throw new Exception("Predictions were not empty!");
                }

                Predictions.Add(p);

                pendingFilter = true;
            }
            else
            {
                if (Application.Current.Properties.ContainsKey("PredictionSort"))
                {
                    switch (Application.Current.Properties["PredictionSort"] as string)
                    {
                    case "Ratings":
                    {
                        var TempList = FilteredShows.AsParallel().Select(x => new PredictionContainer(x, this, average, true, false, UseFinal)).OrderByDescending(x => x.show.AverageRating).ToList();
                        MiniNetwork.AddPredictions_Ratings(TempList, ref Predictions);
                        break;
                    }

                    case "Name":
                    {
                        var TempList = shows.AsParallel().Where(x => x.year == year).Select(x => new PredictionContainer(x, this, average, true, false, UseFinal)).OrderBy(x => x.Name).ThenBy(x => x.Season).ToList();
                        MiniNetwork.AddPredictions_Name(TempList, ref Predictions);
                        break;
                    }

                    default:
                    {
                        Filter_Odds(average, UseFinal);
                        break;
                    }
                    }
                }
                else
                {
                    Filter_Odds(average, UseFinal);
                }
            }
        }

        void Filter_Odds(double average, bool UseFinal = false)
        {
            var tempPredictions = FilteredShows.AsParallel().Select(x => new PredictionContainer(x, this, average, true, false, UseFinal)).OrderByDescending(x => x.odds);

            MiniNetwork.AddPredictions_Odds(tempPredictions, ref Predictions);
        }