/// Public Methods Section


        ///<summary>
        ///
        /// Entry Point of prediction ,requires all systems Initilized and requires DailyMeteoSystem to have a non null observation
        ///
        /// </summary>
        public void StartPrediction()
        {
            if (dailyMeteoSystem.Observation != null)
            {
                predictionManager.DailyObservation = dailyMeteoSystem.Observation;


                queryManager.GenerateQuery(dailyMeteoSystem.Observation);
                PredictionCouple.NUMBER_OF_PARAMETERS = dailyMeteoSystem.Observation.Parameters.Count;


                /// Getting data from dataSet
                dataRetreiver.SetQuery(queryManager.Query);
                dataRetreiver.HandleQuery();
                dataRetreiver.SetObservationTable();
                predictionManager.PredictionCouples = dataRetreiver.GetObservations();
                ///
                if (predictionManager.PredictionCouples != null && mode == CEP)
                {
                    predictionManager.PredictByKNN();
                    resultHandler.Predictions = predictionManager.Predictions;
                    resultHandler.GenerateResults();
                    if (resultHandler.Results != null)
                    {
                        foreach (var prediction in resultHandler.Results)
                        {
                            decisionMaker.SetPredictions(prediction.Predictions);
                            prediction.Climate = decisionMaker.GetDecision();
                        }
                    }
                }
                else if (mode == SELECTION)
                {
                    resultHandler.SetResults(predictionManager.PredictBySelection());
                    if (resultHandler.Results != null)
                    {
                        foreach (var prediction in resultHandler.Results)
                        {
                            decisionMaker.SetPredictions(prediction.Predictions);
                            prediction.Climate = decisionMaker.GetDecision();
                        }
                    }
                }
            }
            else
            {
                throw new NullObservationException("DailyMeteoSystem Has not yet acquired Observation");
            }
        }
示例#2
0
        public void Should_ReturnDecision_When_DecisionExist()
        {
            //Arrange
            var qModel = new QuestionModel
            {
                Keywords  = new string[] { "courses", "learn", "study" },
                Name      = "Searching .Net courses",
                Decisions = new List <DecisionModel>
                {
                    new DecisionModel
                    {
                        Answer    = "We have super hero course for you",
                        Meta      = new string[] { ".net", "1-2 hours", "novice" },
                        Resources = "epam.learn.com/super-hero/courses/web-api"
                    }
                },
                Questions = new List <Question>
                {
                }
            };

            var userAnswers = qaModel.Answers;

            var expectedResult = new DecisionModel
            {
                Answer    = "We have super hero course for you",
                Meta      = new string[] { ".net", "1-2 hours", "novice" },
                Resources = "epam.learn.com/super-hero/courses/web-api"
            };

            //Act
            var actualResult = _decisionMaker.GetDecision(userAnswers, qModel);

            //Assert
            Assert.AreEqual(expectedResult.Answer, actualResult.Answer);
            Assert.AreEqual(expectedResult.Resources, actualResult.Resources);
            Assert.AreEqual(expectedResult.Meta.ToString(), actualResult.Meta.ToString());
        }