Accord.Statistics.Models.Markov.Learning.BaumWelchLearning.Run C# (CSharp) Method

Run() public method

Runs the Baum-Welch learning algorithm for hidden Markov models.
Learning problem. Given some training observation sequences O = {o1, o2, ..., oK} and general structure of HMM (numbers of hidden and visible states), determine HMM parameters M = (A, B, pi) that best fit training data.
public Run ( ) : double
return double
        public double Run(params int[][] observations)
        {
            discreteObservations = observations;

            return base.Run(discreteObservations);
        }

Usage Example

        public StochasticGenerator(MelodySequence[] seqs)
        {
            if(seqs != null && seqs.Length > 0)
                this.base_seq = seqs[0];

            int count = seqs.Length;

            List<int[]> notes = new List<int[]>();

            List<int[]> bayesInputs = new List<int[]>();
            List<int> bayesOutputs = new List<int>();
            notes_map = new Dictionary<int, int>();

            int max_notes = 0;

            int note = 0;
            foreach (MelodySequence m in seqs)
            {
                Note[] song = m.ToArray();

                int[] _notes = new int[song.Length];
                int[] _durations = new int[20];

                for (int i = 0; i < song.Length; i++)
                {
                    var unote = song[i].Pitch + song[i].Duration*128;
                    if (notes_map.ContainsKey(unote))
                        _notes[i] = notes_map[unote];
                    else
                    {
                        notes_map[unote] = note++;
                        _notes[i] = notes_map[unote];
                    }

                }
                notes.Add(_notes);

            }
            max_notes = note;
            Console.WriteLine("Training Pitches");
            pitch_hmm = new HiddenMarkovModel(50, max_notes);
            var teacher = new BaumWelchLearning(pitch_hmm) { Tolerance = 0.0001, Iterations = 0 };
            var __pitches = notes.ToArray();
            teacher.Run(__pitches);
            teacher.Run(__pitches);
            Console.WriteLine("Done training");

            this.MaxGenerations = 2000;
        }
All Usage Examples Of Accord.Statistics.Models.Markov.Learning.BaumWelchLearning::Run