mixexp_plot.m
来自「基于matlab的bayes net toolbox,希望对大家能有些帮助」· M 代码 · 共 50 行
M
50 行
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 inumexp = 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 lpr = exp(eta * x');pr = pr ./ (ones(numexp,1) * sum(pr));% y(i,l) = prediction of expert i for example ly = theta * x';% yg(l) = weighted prediction for example lyg = 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 onplot(data(:,1), data(:,2), '+');hold off
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?