Пример #1
0
        private void RunRl()
        {
            var list             = GetAllModelForWeekday(selectedWeekday);
            var takeNumber       = list.Count;
            var comeHomingValues =
                list.OrderByDescending(u => u.Date)
                .Select(z => new TimeSpan(0, int.Parse(z.Hour), int.Parse(z.Minutes), 0))
                .Take(takeNumber)
                .ToList();
            var xs    = new double[takeNumber];
            var value = 0.1;

            for (var i = 0; i < xs.Length; i++)
            {
                xs[i]  = value;
                value += 0.1;
            }
            var comeHomingHourValues =
                comeHomingValues.Select(y => TimeConverter.ConvertFromTimeToDouble(y.TotalMinutes)).ToArray();
            double r;
            double yintercept;
            double slope;

            LinearRegression.Execute(xs, comeHomingHourValues, 1, takeNumber - 1, out r, out yintercept, out slope);
            var predictionValue = slope * (value + 0.1) + yintercept;

            _predictRL = predictionValue;
        }
Пример #2
0
        private void RunANN()
        {
            var list             = GetAllModelForWeekday(selectedWeekday);
            var takeNumber       = HowManyTake(list.Count);
            var comeHomingValues =
                list.OrderByDescending(u => u.Date)
                .Select(z => new TimeSpan(0, int.Parse(z.Hour), int.Parse(z.Minutes), 0))
                .Take(takeNumber)
                .ToList();

            if (takeNumber < 40)
            {
                var random = new Random();
                for (var i = takeNumber; i < 40; i++)
                {
                    comeHomingValues.Add(comeHomingValues[random.Next(takeNumber)]);
                }
            }
            var comeHomingHourValues =
                comeHomingValues.Select(y => TimeConverter.ConvertFromTimeToDouble(y.TotalMinutes)).ToArray();

            _predict = new NuralNetworkPredictionAlgorithm(comeHomingHourValues);
            _predict.Execute();


            _predict.PredictValue();

            _predictANN = _predict.GetPredictedValue();
        }
Пример #3
0
        private void RunWma()
        {
            var list             = GetAllModelForWeekday(selectedWeekday);
            var takeNumber       = list.Count;
            var comeHomingValues =
                list.OrderByDescending(u => u.Date)
                .Select(z => new TimeSpan(0, int.Parse(z.Hour), int.Parse(z.Minutes), 0))
                .Take(takeNumber)
                .ToList();

            var prediction =
                WMA.WeightedMovingAverage(
                    comeHomingValues.Select(y => TimeConverter.ConvertFromTimeToDouble(y.TotalMinutes)).ToArray(), 1,
                    0.05, 0.15, 0.20, 0.25, 0, 0.35);

            _predictWma = prediction.Value;
        }