Exemple #1
0
        public IPredictionResult Predict(double[][] observations, double[] weights)
        {
            var model = HiddenMarkovModelStateFactory.GetState(new ModelCreationParameters <DiscreteDistribution> {
                Pi = _pi, TransitionProbabilityMatrix = _transitionProbabilityMatrix, Emissions = _emission
            });                                                                                                                                                                                                   //new HiddenMarkovModelState<IMultivariateDistribution>(_pi, _transitionProbabilityMatrix, _emission);

            var request = new PredictionRequest();

            request.TrainingSet  = observations;
            request.NumberOfDays = 1;
            request.Tolerance    = 0.01;

            var predictor = new LikelihoodBasedPredictor();

            return(predictor.Predict((IHiddenMarkovModel <IDistribution>)model, request));
        }
        public IEvaluationResult EvaluatePrediction(IPredictionResult results, double[][] observations)
        {
            var model = (HiddenMarkovModelMultivariateGaussianDistribution)HiddenMarkovModelFactory.GetModel(new ModelCreationParameters <IMultivariateDistribution> {
                Pi = _pi, TransitionProbabilityMatrix = _transitionProbabilityMatrix, Emissions = _emission
            });                                                                                                                                                                                                                                                      //new HiddenMarkovModelState<IMultivariateDistribution>(_pi, _transitionProbabilityMatrix, _emission);

            model.Normalized = Normalized;
            var request = new EvaluationRequest();

            request.PredictionParameters           = new PredictionRequest();
            request.PredictionToEvaluate           = new PredictionResult();
            request.EstimatorType                  = ErrorEstimatorType.Value;
            request.PredictionParameters.Tolerance = PREDICTION_LIKELIHOOD_TOLERANCE;
            request.PredictionParameters.TestSet   = observations;
            request.PredictionToEvaluate.Predicted = results.Predicted;

            var predictor = new LikelihoodBasedPredictor();

            return(predictor.Evaluate(request));
        }