plt.show() # plot the mode of responsibilities modes = model.map_grids[responsibilities.argmax(axis=1), :] plt.figure() # plt.figure(figsize=figure.figaspect(1)) plt.scatter(modes[:, 0], modes[:, 1], c=ytrain) plt.colorbar() plt.ylim(-1.1, 1.1) plt.xlim(-1.1, 1.1) plt.xlabel("z1 (mode)") plt.ylabel("z2 (mode)") plt.show() # construct MLR model model.mlr(Xtrain, ytrain) # MLR prediction predicted_ytest = np.ndarray.flatten(model.mlr_predict(Xtest)) # r2p, RMSEp, MAEp print("r2p: {0}".format(float(1 - sum((ytest - predicted_ytest) ** 2) / sum((ytest - ytest.mean()) ** 2)))) print("RMSEp: {0}".format(float((sum((ytest - predicted_ytest) ** 2) / len(ytest)) ** (1 / 2)))) print("MAEp: {0}".format(float(sum(abs(ytest - predicted_ytest)) / len(ytest)))) # yy-plot plt.figure(figsize=figure.figaspect(1)) plt.scatter(ytest, predicted_ytest) YMax = np.max(np.array([np.array(ytest), predicted_ytest])) YMin = np.min(np.array([np.array(ytest), predicted_ytest])) plt.plot([YMin - 0.05 * (YMax - YMin), YMax + 0.05 * (YMax - YMin)], [YMin - 0.05 * (YMax - YMin), YMax + 0.05 * (YMax - YMin)], 'k-')
plt.xlabel("z1 (mean)") plt.ylabel("z2 (mean)") plt.show() # plot the mode of responsibilities modes = model.map_grids[responsibilities.argmax(axis=1), :] plt.figure() # plt.figure(figsize=figure.figaspect(1)) plt.scatter(modes[:, 0], modes[:, 1], c=original_y) plt.colorbar() plt.ylim(-1.1, 1.1) plt.xlim(-1.1, 1.1) plt.xlabel("z1 (mode)") plt.ylabel("z2 (mode)") plt.show() # construct MLR model model.mlr(original_X, original_y) # inverse analysis estimated_x_mean, estimated_x_mode, responsibilities_inverse = model.inverse_gtm_mlr(autoscaled_target_y_value) estimated_x_mean = estimated_x_mean * original_X.std(axis=0, ddof=1) + original_X.mean(axis=0) estimated_x_mode = estimated_x_mode * original_X.std(axis=0, ddof=1) + original_X.mean(axis=0) # print("estimated x-mean: {0}".format(estimated_x_mean)) print("estimated x-mode: {0}".format(estimated_x_mode)) estimated_x_mean_on_map = responsibilities_inverse.dot(model.map_grids) estimated_x_mode_on_map = model.map_grids[np.argmax(responsibilities_inverse), :] # print("estimated x-mean on map: {0}".format(estimated_x_mean_on_map)) print("estimated x-mode on map: {0}".format(estimated_x_mode_on_map))