// Due Dates
        public KleineServiceApi(IRepositories repo, INotification notify)
        {
            this.repo = repo;
            this.notify = notify;

            // currently static date, we'll add this in the future to be dynamic from the database
            this.outcome = new PredictionOutcome
            {
                Gender = "Female",
                Date = new DateTime(2013, 12, 10),
                Time = new DateTime(2013, 12, 10, 17, 42, 0),
                Weight = 7.2M,
                Length = 20.75M
            };
        }
Beispiel #2
0
        public int PointsFor(PredictionOutcome predictionOutcome)
        {
            switch (predictionOutcome)
            {
            case PredictionOutcome.CorrectScore:
                return(CorrectScorePoints);

            case PredictionOutcome.CorrectOutcome:
                return(CorrectOutcomePoints);

            case PredictionOutcome.IncorrectOutcome:
                return(IncorrectOutcomePoints);

            case PredictionOutcome.NoFixtureScore:
                return(NoFixtureScore);

            default:
                return(0);
            }
        }
Beispiel #3
0
        private void Button1_Click(object sender, EventArgs e)
        {
            Point[] startPoints = GeneratePoints(int.Parse(p_textBox.Text));

            NeuralNetwork network = NeuralNetwork.CreateNetwork(startPoints);

            double alpha        = double.Parse(alpha_textBox.Text);
            double desiredError = double.Parse(e_textBox.Text);
            int    trainPoints  = int.Parse(train_textBox.Text);

            Point[] points = GeneratePoints(trainPoints);

            network.TrainNetwork(alpha, desiredError, points);

            Point[] predictedPoints = network.PredictNextPoints(trainPoints + 20);
            richTextBox1.Clear();
            richTextBox1.Text += $"Alpha = {network.LearningOutcome.alpha}\n";

            Point[] correctPoints = GeneratePoints(trainPoints + 20);

            PredictionOutcome predictionOutcome = new PredictionOutcome();

            predictionOutcome.X              = new double[20];
            predictionOutcome.RealValue      = new double[20];
            predictionOutcome.ReferenceValue = new double[20];

            for (int i = 0, j = trainPoints; i < 20; i++, j++)
            {
                predictionOutcome.X[i]              = Math.Round(correctPoints[j].X, 2);
                predictionOutcome.RealValue[i]      = correctPoints[j].Y;
                predictionOutcome.ReferenceValue[i] = predictedPoints[j].Y;
                richTextBox1.Text += $"X = {predictionOutcome.X[i]} | Real = {predictionOutcome.RealValue[i]} | Reference = {predictionOutcome.ReferenceValue[i]}\n";
            }

            string jsonString = JsonSerializer.Serialize(predictionOutcome);

            File.WriteAllText("predictedPoints.json", jsonString);

            jsonString = JsonSerializer.Serialize(network.LearningOutcome);
            File.WriteAllText("learningOutcome.json", jsonString);
        }
        private PredictionScore getScore(Prediction prediction, PredictionOutcome outcome)
        {
            PredictionScore score = new PredictionScore();

            if (prediction.FinishDate != null)
            {

                var date = (DateTime)prediction.Date;
                var time = ((DateTime)prediction.Time).ToLocalTime();
                time = new DateTime(2013, 12, 10, time.Hour, time.Minute, 0);

                if (prediction.Gender == outcome.Gender)
                    score.Gender = 3;

                if (date.Month == outcome.Date.Month && date.Day == outcome.Date.Day)
                    score.Date = 5;

                var timedif = (outcome.Time - time);

                if (timedif.TotalHours <= 4 && timedif.TotalHours >= 0)
                    score.Time = 4;

                if (prediction.Weight <= outcome.Weight && prediction.Weight <= (outcome.Weight + 1.5M))
                    score.Weight = 2;

                if (prediction.Length <= outcome.Length && outcome.Length <= prediction.Length + 2M)
                    score.Length = 1;

            }
            return score;
        }