@@ -424,7 +424,7 @@ function plot2d(obj, truthfun, varargin)
424
424
425
425
% Generate grid where the mean and variance will be calculated
426
426
if numel(varargin ) ~= 2
427
- factor = 0.3 ;
427
+ factor = 0.3 ;% 0.3;
428
428
rangeX1 = [ min(obj .X(1 ,: )) - factor * range(obj .X(1 ,: )), ...
429
429
max(obj .X(1 ,: )) + factor * range(obj .X(1 ,: )) ];
430
430
rangeX2 = [ min(obj .X(2 ,: )) - factor * range(obj .X(2 ,: )), ...
@@ -463,6 +463,7 @@ function plot2d(obj, truthfun, varargin)
463
463
surf(X1 ,X2 ,Ymean - 2 * Ystd ,Ystd , ' FaceAlpha' ,0.3 )
464
464
scatter3(obj .X(1 ,: ),obj .X(2 ,: ),obj .Y(: ,pi ),' filled' ,' MarkerFaceColor' ,' red' )
465
465
title(' mean\pm2*stddev Prediction Curves' )
466
+ xlabel(' X1' ); ylabel(' X2' );
466
467
shading interp ;
467
468
colormap(gcf ,jet );
468
469
view(30 ,30 )
@@ -475,29 +476,31 @@ function plot2d(obj, truthfun, varargin)
475
476
scatter3(obj .X(1 ,: ),obj .X(2 ,: ),obj .Y(: ,pi ),' filled' ,' MarkerFaceColor' ,' red' , ' DisplayName' , ' Sample points' )
476
477
zlim([ min(obj .Y(: ,pi ))-range(obj .Y(: ,pi )),max(obj .Y(: ,pi ))+range(obj .Y(: ,pi )) ]);
477
478
legend ;
478
- xlabel(' X1' ); ylabel(' X2' );
479
479
title(' True Function' )
480
+ xlabel(' X1' ); ylabel(' X2' );
480
481
view(24 ,12 )
481
482
subplot(1 ,2 ,2 ); hold on ; grid on ;
482
483
% surf(X1,X2,Y, 'FaceAlpha',.5, 'FaceColor','b', 'EdgeColor', 'none', 'DisplayName', 'True function');
483
484
surf(X1 ,X2 ,Ymean , ' FaceAlpha' ,.8 , ' EdgeColor' , ' none' , ' DisplayName' , ' Prediction mean' );
484
485
scatter3(obj .X(1 ,: ),obj .X(2 ,: ),obj .Y(: ,pi ),' filled' ,' MarkerFaceColor' ,' red' , ' DisplayName' , ' Sample points' )
485
486
zlim([ min(obj .Y(: ,pi ))-range(obj .Y(: ,pi )),max(obj .Y(: ,pi ))+range(obj .Y(: ,pi )) ]);
486
487
legend ;
487
- xlabel(' X1' ); ylabel(' X2' );
488
488
title(' Prediction Mean' )
489
+ xlabel(' X1' ); ylabel(' X2' );
489
490
view(24 ,12 )
490
491
491
492
% plot bias and variance
492
493
figure(' Color' ,' w' , ' Position' ,[-1260 547 894 264 ])
493
494
subplot(1 ,2 ,1 ); hold on ; grid on ;
494
495
contourf(X1 ,X2 , abs(Ymean - Ytrue ), 50 ,' LineColor' ,' none' )
495
496
title(' Absolute Prediction Bias' )
497
+ xlabel(' X1' ); ylabel(' X2' );
496
498
colorbar ;
497
499
scatter(obj .X(1 ,: ),obj .X(2 ,: ),' filled' ,' MarkerFaceColor' ,' red' )
498
500
subplot(1 ,2 ,2 ); hold on ; grid on ;
499
501
contourf(X1 ,X2 , Ystd .^ 2 , 50 ,' LineColor' ,' none' )
500
502
title(' Prediction Variance' )
503
+ xlabel(' X1' ); ylabel(' X2' );
501
504
colorbar ;
502
505
scatter(obj .X(1 ,: ),obj .X(2 ,: ),' filled' ,' MarkerFaceColor' ,' red' )
503
506
colormap(gcf ,parula );
@@ -524,35 +527,3 @@ function plot1d(obj, truthfun, varargin)
524
527
end
525
528
end
526
529
end
527
-
528
-
529
-
530
-
531
-
532
-
533
-
534
-
535
-
536
-
537
- % function cost = optimizeHyperParams_gradfun(obj,outdim,vars)
538
- %
539
- % var_f = vars(1);
540
- % M = diag(vars(2:end));
541
- %
542
- % K = var_f * exp( -0.5 * pdist2(obj.X',obj.X','mahalanobis',M).^2 );
543
- %
544
- % alpha = K \ obj.Y(:,outdim);
545
- %
546
- % dK_var_f = K*2/sqrt(var_f);
547
- %
548
- % dK_l = zeros(obj.N,obj.N);
549
- % for i=1:obj.N
550
- % for j=1:obj.N
551
- % ksi = obj.X(:,i) - obj.X(:,j);
552
- % % dK_l(i,j) = sum( K(i,j)*0.5*inv(M)*ksi*ksi'*inv(M) * log(diag(M)) );
553
- % dK_l(i,j) = sum( K(i,j)*0.5*M\ksi*ksi'/M * log(diag(M)) );
554
- % end
555
- % end
556
- % % cost = 0.5 * trace( (alpha*alpha' - inv(K)) * ( dK_var_f + dK_l ) );
557
- % cost = 0.5 * trace( alpha*alpha'*(dK_var_f+dK_l) - K\(dK_var_f+dK_l) );
558
- % end
0 commit comments