Mercurial > hg > camir-aes2014
comparison 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 | 
   comparison
  equal
  deleted
  inserted
  replaced
| -1:000000000000 | 0:e9a9cd732c1e | 
|---|---|
| 1 function plot_mixexp(theta, eta, data) | |
| 2 % PLOT_MIXEXP Plot the results for a piecewise linear regression model | |
| 3 % plot_mixexp(theta, eta, data) | |
| 4 % | |
| 5 % data(l,:) = [x y] for example l | |
| 6 % theta(i,:) = regression vector for expert i | |
| 7 % eta(i,:) = softmax (gating) params for expert i | |
| 8 | |
| 9 numexp = size(theta, 1); | |
| 10 | |
| 11 mn = min(data); | |
| 12 mx = max(data); | |
| 13 xa = mn(1):0.01:mx(1); | |
| 14 x = [ones(length(xa),1) xa']; | |
| 15 % pr(i,l) = posterior probability of expert i on example l | |
| 16 pr = exp(eta * x'); | |
| 17 pr = pr ./ (ones(numexp,1) * sum(pr)); | |
| 18 % y(i,l) = prediction of expert i for example l | |
| 19 y = theta * x'; | |
| 20 % yg(l) = weighted prediction for example l | |
| 21 yg = sum(y .* pr)'; | |
| 22 | |
| 23 subplot(3,2,1); | |
| 24 plot(xa, y(1,:)); | |
| 25 title('expert 1'); | |
| 26 | |
| 27 subplot(3,2,2); | |
| 28 plot(xa, y(2,:)); | |
| 29 title('expert 2'); | |
| 30 | |
| 31 subplot(3,2,3); | |
| 32 plot(xa, pr(1,:)); | |
| 33 title('gating 1'); | |
| 34 | |
| 35 subplot(3,2,4); | |
| 36 plot(xa, pr(2,:)); | |
| 37 title('gating 2'); | |
| 38 | |
| 39 subplot(3,2,5); | |
| 40 plot(xa, yg); | |
| 41 axis([-1 1 -1 2]) | |
| 42 title('prediction'); | |
| 43 | |
| 44 subplot(3,2,6); | |
| 45 title('data'); | |
| 46 hold on | |
| 47 plot(data(:,1), data(:,2), '+'); | |
| 48 hold off | |
| 49 | 
