y_m = np.mean(y, axis=0) y_s = np.std(y, axis=0) y = Normalize(y, y_m, y_s) y_star = Normalize(y_star, y_m, y_s) ModelInfo.update({"X": X}) ModelInfo.update({"y": y}) # Training train() # Prediction mean_star, var_star = predict(X_star) # Plot Results Z = ModelInfo["Z"] m = ModelInfo["m"] plt.figure(1) plt.plot(X, y, 'b+', alpha=0.1) plt.plot(Z, m, 'ro', alpha=1) plt.plot(X_star, y_star, 'b-') plt.plot(X_star, mean_star, 'r--') lower = mean_star - 2.0 * np.sqrt(var_star) upper = mean_star + 2.0 * np.sqrt(var_star) plt.fill_between(X_star.flatten(), lower.flatten(), upper.flatten(), facecolor='orange', alpha=0.5)
mean_star, var_star = pgp.predict(X_star) # Plot Results Z = pgp.sess.run(pgp.Z) m = pgp.sess.run(pgp.m) plt.figure(figsize=(10,10)) plt.rc('text', usetex=True) plt.rcParams.update({'font.size': 15}) plt.subplot(2, 1, 1) plt.plot(X,y,'b+',alpha=1) plt.xlabel('$x$') plt.ylabel('$f(x)$') plt.title('(A)') plt.legend(['%d traning Data' % N], loc='lower left') plt.subplot(2, 1, 2) plt.plot(Z,m, 'ro', alpha=1, markersize=14) plt.plot(X_star, y_star, 'b-', linewidth=2) plt.plot(X_star, mean_star, 'r--', linewidth=2) lower = mean_star - 2.0*np.sqrt(var_star) upper = mean_star + 2.0*np.sqrt(var_star) plt.fill_between(X_star.flatten(), lower.flatten(), upper.flatten(), facecolor='orange', alpha=0.5) plt.xlabel('$x$') plt.ylabel('$f(x), \overline{f}(x)$') plt.title('(B)') plt.tight_layout() plt.legend(['%d hypothetical data' % M, '$f(x)$', '$\overline{f}(x)$', 'Two standard deviations'], loc='lower left') plt.savefig('../Fig/OneDimensional.eps', format='eps', dpi=1000)