输出结果
代码设计
load spectra_data.mat
temp = randperm(size(NIR,1));
P_train = NIR(temp(1:50),:)';
T_train = octane(temp(1:50),:)';
P_test = NIR(temp(51:end),:)';
T_test = octane(temp(51:end),:)';
N = size(P_test,2);
net = newrbe(P_train,T_train,0.3);
w1=net.iW{1,1}
isequal(w1',P_train)
b1=net.b{1}
T_sim = sim(net,P_test);
error = abs(T_sim - T_test)./T_test;
R2 = (N * sum(T_sim .* T_test) - sum(T_sim) * sum(T_test))^2 / ((N * sum((T_sim).^2) - (sum(T_sim))^2) * (N * sum((T_test).^2) - (sum(T_test))^2));
result = [T_test' T_sim' error']
figure
plot(1:N,T_test,'b:*',1:N,T_sim,'r-o')
legend('真实值','预测值')
xlabel('预测样本')
ylabel('辛烷值')
string = {'RBF:RBF实现测试集辛烷值含量预测结果对比—Jason niu';['R^2=' num2str(R2)]};
title(string)