def cluster_border_plot(centers):
    rand_data_number = 1500
    rand_data = create_rand_data(dataa, rand_data_number, dimension_size)
    rand_data = rand_data.T[:len(rand_data.T) - 1].T
    membership = FCM.cal_membership(rand_data, centers, len(centers),
                                    len(rand_data), 2)
    FCM.plot(membership, centers, rand_data)
def test(test_dataa, test_dataa_size, cluster_size, m, centers, W, gama):
    test_data = test_dataa.T[:len(test_dataa.T) - 1].T
    membership_test = FCM.cal_membership(test_data, centers, cluster_size,
                                         test_dataa_size, m)
    G = cal_G(test_data, centers, membership_test, gama, test_dataa_size)
    G = np.array(G)
    yh = G @ W
    yhat = []
    for r in range(0, test_dataa_size):
        argmax = np.argmax(yh[r])
        yhat.append(argmax)
        # test_data[r].append(argmax)

    scatter(test_dataa)
    # scatter(test_data)
    plt.figure()

    f1 = f2 = 0
    for uo in range(0, len(test_data)):
        if yhat[uo] == 1:
            if f1 == 0:
                plt.scatter(test_data[uo][0],
                            test_data[uo][1],
                            color='red',
                            label='Label=1')
                f1 = 1
            else:
                plt.scatter(test_data[uo][0], test_data[uo][1], color='red')
        else:
            if f2 == 0:
                plt.scatter(test_data[uo][0],
                            test_data[uo][1],
                            color='blue',
                            label='Label=0')
                f2 = 1
            else:
                plt.scatter(test_data[uo][0], test_data[uo][1], color='blue')

    plt.title('Scattered data!')
    plt.legend(loc="upper left")
    plt.show()

    accuracy = 0
    for ty in range(0, test_dataa_size):
        if (test_dataa[ty][2] == 1.0
                and yhat[ty] == 1.0) or (test_dataa[ty][2] == -1.0
                                         and yhat[ty] == 0):
            accuracy = accuracy + 1
    accuracy = accuracy / test_dataa_size * 100
    print('accuracy is ', accuracy)