Gaussian Process Classification (GPC) on the XOR Dataset in Scikit-learn

This example illustrates GPC on XOR data. Compared are a stationary, isotropic kernel (RBF) and a non-stationary kernel (DotProduct). On this particular dataset, the DotProduct kernel obtains considerably better results because the class-boundaries are linear and coincide with the coordinate axes. In general, stationary kernels often obtain better results.

titles=[]plots=[[],[]]fori,kernelinenumerate(kernels):clf=GaussianProcessClassifier(kernel=kernel,warm_start=True).fit(X,Y)# plot the decision function for each datapoint on the gridZ=clf.predict_proba(np.vstack((xx.ravel(),yy.ravel())).T)[:,1]Z=Z.reshape(xx.shape)contours=go.Heatmap(x=x_,y=y_,z=Z,colorscale=cmap1)plots[i].append(contours)scatter=go.Scatter(x=X[:,0],y=X[:,1],showlegend=False,mode='markers',marker=dict(color=X[:,0],colorscale=cmap2,showscale=False,line=dict(color='black',width=1)))plots[i].append(scatter)titles.append("%s<br> Log-Marginal-Likelihood:%.3f"%(clf.kernel_,clf.log_marginal_likelihood(clf.kernel_.theta)))