GithubHelp home page GithubHelp logo

Comments (2)

kennethmorton avatar kennethmorton commented on July 20, 2024

Sorry about this. Definitely a bug. I just pushed a fix. Keep in mind that the timeseries and HMM stuff is in beta. No guarantees. To validate the bug fix try this test script.

Thanks and good luck,
Kenny

prtPath( 'alpha', 'beta' ); % make sure prtDataSetTimeSeries is on path

% Generate two HMMs for drawing data
% The second one has a flipped transition matrix.
A = [.9 .1 0; 0 .9 .1; .1 0 .9];
gaussians = repmat(prtRvMvn('sigma',eye(2)),3,1);
gaussians(1).mu = [-2 -2];
gaussians(2).mu = [2 -2];
gaussians(3).mu = [2 2];

sourceHmm1 = prtRvHmm('pi',[1 1 1]/3,...
    'transitionMatrix',A,...
    'components',gaussians);

sourceHmm2 = prtRvHmm('pi',[1 1 1]/3,...
    'transitionMatrix',flipud(A),...
    'components',gaussians);

% Draw data from these HMMs
nTimeSeriesPerClass = 50;
nSamplesPerTimeSeries = 100;

x = cat(1,sourceHmm1.draw(ones(1,nTimeSeriesPerClass)*nSamplesPerTimeSeries),sourceHmm2.draw(ones(1,nTimeSeriesPerClass)*nSamplesPerTimeSeries));
y = prtUtilY(nTimeSeriesPerClass,nTimeSeriesPerClass);

% Place into to a dataSetTimeSeries
ds = prtDataSetTimeSeries(x,y);
ds.classNames = {'Class A','Class flipud(A)'};

% Train a MAP classifier that uses HMMs to model each class
class = train(prtClassMap('rvs',prtRvHmm('components',repmat(prtRvMvn,3,1))),ds);

% Evaluate the classifier (Note: No cross-validation is performed here!!!
out = run(class,ds); % Note: out is a prtDataSetClass
prtScoreRoc(out)


% Plot the learned HMM parameters
figure
subplot(2,4,1)
class.rvs(1).components(1).plotPdf([-5 5 -5 5])
title('Class 1 Component 1 pdf')
subplot(2,4,2)
class.rvs(1).components(2).plotPdf([-5 5 -5 5])
title('Class 1 Component 2 pdf')
subplot(2,4,3)
class.rvs(1).components(3).plotPdf([-5 5 -5 5])
title('Class 1 Component 3 pdf')
subplot(2,4,4)
prtUtilPlotMatrixTable(class.rvs(1).transitionMatrix);
title('Class 1 Transition Matrix')

subplot(2,4,5)
class.rvs(2).components(1).plotPdf([-5 5 -5 5])
title('Class 2 Component 1 pdf')
subplot(2,4,6)
class.rvs(2).components(2).plotPdf([-5 5 -5 5])
title('Class 2 Component 2 pdf')
subplot(2,4,7)
class.rvs(2).components(3).plotPdf([-5 5 -5 5])
title('Class 2 Component 3 pdf')
subplot(2,4,8)
prtUtilPlotMatrixTable(class.rvs(2).transitionMatrix);
title('Class 2 Transition Matrix')

from prt.

StevenLOL avatar StevenLOL commented on July 20, 2024

Test script reports no problem. Thank you for the quick response.

from prt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.