示例#1
0
        public void Predict_VideoViewsSeriesAndRegularErgodicModelAnd30DaysTestSequence_PredictionResult()
        {
            var util   = new TestPipedDataUtils();
            var series = util.GetSvcData(util.VideoViewsFilePath, new DateTime(2014, 01, 01), new DateTime(2014, 05, 31));
            var test   = util.GetSvcData(util.VideoViewsFilePath, new DateTime(2014, 06, 01), new DateTime(2014, 06, 30));

            var model = (HiddenMarkovModelMixtureDistribution)HiddenMarkovModelFactory.GetModel <HiddenMarkovModelMixtureDistribution, Mixture <IMultivariateDistribution> >(
                new ModelCreationParameters <Mixture <IMultivariateDistribution> >()
            {
                NumberOfComponents = _NumberOfComponents,
                NumberOfStates     = _NumberOfStates
            });

            model.Normalized = true;
            model.Train(series, _NumberOfIterations, _LikelihoodTolerance);
            var result = model.Predict(PredictorType.HmmLikelihood, series, test, 30, _NumberOfIterations, _LikelihoodTolerance);

            util.SaveToFile("regular_data.csv", test, result.Predicted);
            Assert.IsNotNull(result);
            Assert.AreEqual(30, result.Predicted.Length);
        }
示例#2
0
        public void Predict_ModelAndPredictionRequest_PredictedValue()
        {
            var util   = new TestPipedDataUtils();
            var series = util.GetSvcData(util.VideoViewsFilePath, new DateTime(2014, 01, 01), new DateTime(2014, 06, 01));

            var model = (HiddenMarkovModelMixtureDistribution)HiddenMarkovModelFactory.GetModel(new ModelCreationParameters <Mixture <IMultivariateDistribution> >()
            {
                NumberOfComponents = _NumberOfComponents, NumberOfStates = _NumberOfStates
            });

            model.Normalized = true;
            model.Train(series, _NumberOfIterations, _LikelihoodTolerance);
            var request = new SearchBasedPredictionRequest();

            request.TrainingSet  = series;
            request.NumberOfDays = 10;

            var result = model.Predict(PredictorType.HmmLikelihood, series, _NumberOfIterations, _LikelihoodTolerance);

            Assert.AreEqual(0, 0);//result.Predicted);
        }