Using HMM for Clustering

28 views
Skip to first unread message

eli mizzou

unread,
Jan 30, 2013, 5:39:55 PM1/30/13
to cognitiv...@googlegroups.com
Hi,

I was looking for a HMM java package to use it in my project and found this package interesting. First of all, thanks for your effort. Second, I have a data set of time series and I want to build a HMM based on that to do clustering.
So I wanna use Baum-Welch algorithm to predict the model.
I took a look at examples but non of them were about how to use this package to use hmm.

I appreciate any help or hint in for my question. Please let me know what are the steps that I need to take for using Baum-Welch algorithm to predict the model based on my dataset.

_eli

Dixon, Kevin R

unread,
Jan 30, 2013, 10:19:04 PM1/30/13
to cognitiv...@googlegroups.com
Hi Eli,

Thanks for the note.  We typically direct people to the unit tests if there's no direct Example that shows how to use a particular package. Let me know if this sample from the unit test helps explain things:

    /**
     * Learn
     */
    public void testMultiSequenceLearn()
    {
        System.out.println( "Multi-sequence learn" );

        HiddenMarkovModel<Vector> target = this.createHMMInstance();
        final int numSequences = 100;
        ArrayList<ArrayList<Vector>> sequences =
            new ArrayList<ArrayList<Vector>>( numSequences );
        for( int k = 0; k < numSequences; k++ )
        {
            sequences.add( target.sample(RANDOM, 10) );
        }

        DefaultMultiCollection<Vector> data =
            new DefaultMultiCollection<Vector>( sequences );
        sequences = null;

        System.out.println( "TARGET: " + target );
        double l1 = target.computeMultipleObservationLogLikelihood(data.subCollections());
        System.out.println( "TARGET Log Likelihood: " + l1 );

        // FALSE: Result Log Likelihood: -114550.38265183996
        BaumWelchAlgorithm<Vector> learner = this.createInstance();
        learner.setReestimateInitialProbabilities(true);
        double l0 = learner.getInitialGuess().computeMultipleObservationLogLikelihood( data.subCollections() );
        System.out.println( "INITIAL Log Likelihood: " + l0 );
        learner.setMaxIterations(1000);

        HiddenMarkovModel<Vector> result = learner.learn(data);
        System.out.println( "Result: " + learner.getIteration() + ": " + result );
        double l2 = result.computeMultipleObservationLogLikelihood(data.subCollections());
        System.out.println( "Result Log Likelihood: " +  l2 );

    }


--
Kevin R. Dixon
Sandia National Laboratories
Critical Systems Security (05621)
MS0622, TA-I: 729/134
tel: (505) 284-5615
fax: (505) 284-3258


From: cognitiv...@googlegroups.com [cognitiv...@googlegroups.com] on behalf of eli mizzou [eli....@gmail.com]
Sent: Wednesday, January 30, 2013 3:39 PM
To: cognitiv...@googlegroups.com
Subject: [EXTERNAL] [Cognitive Foundry] Using HMM for Clustering

--
You received this message because you are subscribed to the Google Groups "Cognitive Foundry" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cognitive-foun...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Dixon, Kevin R

unread,
Jan 31, 2013, 5:14:13 PM1/31/13
to eli mizzou, cognitiv...@googlegroups.com

Hi Eli,

 

No problem at all.   When I downloaded the Source files:

 

http://foundry.sandia.gov/releases/3.3.2/CognitiveFoundry-3.3.2-source.zip

 

In the folder:

 

\CognitiveFoundry-3.3.2-source.zip\CognitiveFoundry-3.3.2-source\Components\LearningCore\Test\gov\sandia\cognition\learning\algorithm\hmm

 

Should contain the unit test files I mentioned.

 

Let me know if that helps…

 

Thanks again,

Kevin

 

--

Kevin R. Dixon

Sandia National Laboratories

Critical Systems Security (05621)

MS0672, TA-I: 729/134

From: eli mizzou [mailto:eli....@gmail.com]
Sent: Thursday, January 31, 2013 1:30 PM
To: Dixon, Kevin R
Subject: Fwd: [EXTERNAL] [Cognitive Foundry] Using HMM for Clustering

 

 

Hi,

Thank you so much for your help. This is exactly what I needed. However, I can't see where to find the unit tests related to each package (I'm new to java forgive me for probably my simple questions)!

I just downloaded  "gov-sandia-cognition-learning-core-3.3.2.jar" and added to my java project library.

So, in the example you provided, my program can not find "createInstance()" since it is inherited (this.createInstance();). I tried to find the related unit tests, but no success. I'm assuming unit tests are not publicly available.

 

I appreciate your help and time.

-Eli

eli mizzou

unread,
Jan 31, 2013, 3:14:05 PM1/31/13
to cognitiv...@googlegroups.com
Hi,

Thank you so much for your help. This is exactly what I needed. However, I can't see where to find the unit tests related to each package (I'm new to java forgive me for probably my simple questions)!
I just downloaded  "gov-sandia-cognition-learning-core-3.3.2.jar" and added to my java project library.
So, in the example you provided, my program can not find "createInstance()" since it is inherited (this.createInstance();). I tried to find the related unit tests, but no success. I'm assuming unit tests are not publicly available.

I appreciate your help and time.

-Eli
On Wed, Jan 30, 2013 at 9:19 PM, Dixon, Kevin R <krd...@sandia.gov> wrote:
Reply all
Reply to author
Forward
0 new messages