plt.show()
        # plot the mode of responsibilities
        plt.scatter(modes[:, 0],
                    modes[:, 1],
                    c=variables_train.iloc[:, y_number])
        plt.colorbar()
        plt.ylim(-1.1, 1.1)
        plt.xlim(-1.1, 1.1)
        plt.xlabel('z1 (mode)')
        plt.ylabel('z2 (mode)')
        plt.show()

    # GTMR prediction
    # Forward analysis (Regression)
    mean_of_estimated_mean_of_y, mode_of_estimated_mean_of_y, responsibilities_y, py = \
        model.predict(autoscaled_variables_test.iloc[:, numbers_of_x], numbers_of_x, numbers_of_y)

    # Inverse analysis
    mean_of_estimated_mean_of_x, mode_of_estimated_mean_of_x, responsibilities_y, py = \
        model.predict(autoscaled_variables_test.iloc[:, numbers_of_y], numbers_of_y, numbers_of_x)

    # Check results of forward analysis (regression)
    print('Results of forward analysis (regression)')
    predicted_y_test_all = mode_of_estimated_mean_of_y.copy()
    plt.rcParams['font.size'] = 18
    for index, y_number in enumerate(numbers_of_y):
        predicted_y_test = np.ndarray.flatten(predicted_y_test_all[:, index])
        predicted_y_test = predicted_y_test * variables_train.iloc[:, y_number].std(
            ddof=1) + variables_train.iloc[:, y_number].mean()
        # yy-plot
        plt.figure(figsize=figure.figaspect(1))
Exemplo n.º 2
0
        plt.xlim(-1.1, 1.1)
        plt.xlabel('z1 (mean)')
        plt.ylabel('z2 (mean)')
        plt.show()
        # plot the mode of responsibilities
        plt.scatter(modes[:, 0], modes[:, 1], c=variables[:, y_number])
        plt.colorbar()
        plt.ylim(-1.1, 1.1)
        plt.xlim(-1.1, 1.1)
        plt.xlabel('z1 (mode)')
        plt.ylabel('z2 (mode)')
        plt.show()

    # GTMR prediction for inverse analysis
    mean_of_estimated_mean_of_x, mode_of_estimated_mean_of_x, responsibilities_y, py = \
        model.predict(autoscaled_target_y_value, numbers_of_y, numbers_of_x)

    # Check results of inverse analysis
    print('Results of inverse analysis')
    mean_of_estimated_mean_of_x = mean_of_estimated_mean_of_x * x.std(
        axis=0, ddof=1) + x.mean(axis=0)
    mode_of_estimated_mean_of_x = mode_of_estimated_mean_of_x * x.std(
        axis=0, ddof=1) + x.mean(axis=0)
    #    print('estimated x-mean: {0}'.format(mean_of_estimated_mean_of_x))
    print('estimated x-mode: {0}'.format(mode_of_estimated_mean_of_x))

    estimated_x_mean_on_map = responsibilities_y.dot(model.map_grids)
    estimated_x_mode_on_map = model.map_grids[np.argmax(responsibilities_y), :]
    #    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))