Example #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;
        }