size=10;
X = zeros((size+1)*(size+1),3);
tick = zeros(size+1,1);
for i = 0:size
  tick(i+1) = i/(size+1.0);
  for j = 0:size
    ij = (size+1)*j+i+1;
    X(ij,1) = 1.0;
    X(ij,2) = i/(size+1.0);
    X(ij,3) = j/(size+1.0);
  end
end

b = [1.2573658, -1.4135946, -0.4723616]';

pred = X*b;

Z = zeros(size+1,size+1);
C = zeros(size+1,size+1);
Z0 = zeros(size+1,size+1);
C0 = zeros(size+1,size+1);
for i = 0:size
  for j = 0:size
    ij = (size+1)*j+i+1;
    Z(i+1,j+1)=pred(ij);
    C(i+1,j+1)=-0.3;
    Z0(i+1,j+1) = 0.5;
    if (pred(ij)<0.5)
      C0(i+1,j+1) = 0.39;
    else
      C0(i+1,j+1) = 1.06; 
    end
  end
end

train = load('loans.dat');

minZ=min(min(Z));
maxZ=max(max(Z));

colormap('default');
brighten(0.0);

x=zeros(1,1);
y=x;
z=x;

figure(1); close;

figure(1);
set(gcf,'Position',[500,100,450,582]);
set(gcf,'PaperPosition',[0,0,7.0,7.0]);

mesh(tick,tick,Z,C);
hold on;
mesh(tick,tick,Z0,C0);
view(15.0,8.0);
caxis([minZ,maxZ]);
for i=1:250
  x(1)=train(i,1);
  y(1)=train(i,2);
  z(1)=train(i,3);
  if (z(1) > 0.5)
    plot3(x,y,z,'r.','MarkerSize',15);
  else
    plot3(x,y,z,'g.','MarkerSize',15);
  end
end

hold off;

print -r300 -depsc2 regr00.eps;
