Mercurial > hg > camir-aes2014
diff toolboxes/FullBNT-1.0.7/bnt/examples/static/Misc/mixexp_plot.m @ 0:e9a9cd732c1e tip
first hg version after svn
author | wolffd |
---|---|
date | Tue, 10 Feb 2015 15:05:51 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/toolboxes/FullBNT-1.0.7/bnt/examples/static/Misc/mixexp_plot.m Tue Feb 10 15:05:51 2015 +0000 @@ -0,0 +1,49 @@ +function plot_mixexp(theta, eta, data) +% PLOT_MIXEXP Plot the results for a piecewise linear regression model +% plot_mixexp(theta, eta, data) +% +% data(l,:) = [x y] for example l +% theta(i,:) = regression vector for expert i +% eta(i,:) = softmax (gating) params for expert i + +numexp = size(theta, 1); + +mn = min(data); +mx = max(data); +xa = mn(1):0.01:mx(1); +x = [ones(length(xa),1) xa']; +% pr(i,l) = posterior probability of expert i on example l +pr = exp(eta * x'); +pr = pr ./ (ones(numexp,1) * sum(pr)); +% y(i,l) = prediction of expert i for example l +y = theta * x'; +% yg(l) = weighted prediction for example l +yg = sum(y .* pr)'; + +subplot(3,2,1); +plot(xa, y(1,:)); +title('expert 1'); + +subplot(3,2,2); +plot(xa, y(2,:)); +title('expert 2'); + +subplot(3,2,3); +plot(xa, pr(1,:)); +title('gating 1'); + +subplot(3,2,4); +plot(xa, pr(2,:)); +title('gating 2'); + +subplot(3,2,5); +plot(xa, yg); +axis([-1 1 -1 2]) +title('prediction'); + +subplot(3,2,6); +title('data'); +hold on +plot(data(:,1), data(:,2), '+'); +hold off +