Dear all,
I tried to make a surface plot of the gaussian process function with the following code:
gprMdl = fitrgp(X,Y1,'KernelFunction','squaredexponential','OptimizeHyperparameters','auto','HyperparameterOptimizationOptions',struct('AcquisitionFunctionName','expected-improvement-plus'));ypred = predict(gprMdl,X);[X1,X2] = meshgrid(0.1:0.1:0.9,0.1:0.1:0.9);surf(X1,X2,reshape(ypred,9,9));hold onplot3(X(:,1),X(:,2),Y1,'.r','DisplayName','Observations')
Where the result is presented below.
However, I would expect something more like this. Because the surface plot I have now doesn't fit the data properly and the contour lines are widespread. What am I doing wrong here?
I also tried the following with the help of another post (https://nl.mathworks.com/matlabcentral/answers/407736-plot-3d-hyperplane-from-fitcsvm-results#answer_326570)
But this doens't seem sufficient either.
[x,y]=meshgrid(0.1:0.01:0.9,0.1:0.01:0.9);xGrid = [x(:),y(:)];gprMdl = fitrgp(X,Y1,'KernelFunction','squaredexponential','OptimizeHyperparameters','auto','HyperparameterOptimizationOptions',struct('AcquisitionFunctionName','expected-improvement-plus'));[~,f]=predict(gprMdl2,xGrid);f=reshape(f(:,1),size(x));figuresurf(x,y,f)hold onplot3(X(:,1),X(:,2),Y1,'.r','DisplayName','Observations')
Best Answer