예제 #1
0
def main():
    features, labels = three_dimension.generate_data()
    three_dimension.show_data(features, labels)

    pca = PCA(features, 2)
    res = np.array(pca.process())
    # print(res)

    plt.title('Reduced three dimensions data.')
    plt.scatter(res[np.argwhere(labels == 0), 0], res[np.argwhere(labels == 0), 1], c='b')
    plt.scatter(res[np.argwhere(labels == 1), 0], res[np.argwhere(labels == 1), 1], c='g')
    plt.show()
    plt.close()

    dots, labels = two_dimension.generate_data()
    two_dimension.show_data(dots, labels)

    pca = PCA(dots, 1)
    res = np.array(pca.process())
    # print(res)

    plt.title('Reduced two dimensions data.')
    plt.scatter(res[np.argwhere(labels == 0), 0], np.zeros(shape=res[np.argwhere(labels == 0), 0].shape), c='b')
    plt.scatter(res[np.argwhere(labels == 1), 0], np.zeros(shape=res[np.argwhere(labels == 0), 0].shape), c='g')
    plt.show()
    plt.close()
예제 #2
0
def main():
    features, labels = three_dimension.generate_data()
    three_dimension.show_data(features, labels)

    dne = DNE(features, labels, 2)
    res = np.array(dne.process())
    # print(res)

    plt.title('Reduced three dimensions data.')
    plt.scatter(res[np.argwhere(labels == 0), 0], res[np.argwhere(labels == 0), 1], c='b')
    plt.scatter(res[np.argwhere(labels == 1), 0], res[np.argwhere(labels == 1), 1], c='g')
    plt.show()
    plt.close()
예제 #3
0
def main():
    marker = 'x'

    features, labels = three_dimension.generate_data()
    three_dimension.show_data(features, labels)

    pca = PCA(copy.deepcopy(features), 2)
    res = np.array(pca.process())
    # print(res)

    plt.title('PCA')
    plt.scatter(res[np.argwhere(labels == 0), 0],
                res[np.argwhere(labels == 0), 1],
                c='b',
                marker=marker)
    plt.scatter(res[np.argwhere(labels == 1), 0],
                res[np.argwhere(labels == 1), 1],
                c='g',
                marker=marker)
    plt.show()
    plt.close()

    dne = DNE(copy.deepcopy(features), labels, 2)
    res = np.array(dne.process())
    # print(res)

    plt.title('DNE')
    plt.scatter(res[np.argwhere(labels == 0), 0],
                res[np.argwhere(labels == 0), 1],
                c='b',
                marker=marker)
    plt.scatter(res[np.argwhere(labels == 1), 0],
                res[np.argwhere(labels == 1), 1],
                c='g',
                marker=marker)
    plt.show()
    plt.close()

    lpp = LPP(copy.deepcopy(features), 2, t=200)
    res = np.array(lpp.process())
    # print(res)

    plt.title('LPP')
    plt.scatter(res[np.argwhere(labels == 0), 0],
                res[np.argwhere(labels == 0), 1],
                c='b',
                marker=marker)
    plt.scatter(res[np.argwhere(labels == 1), 0],
                res[np.argwhere(labels == 1), 1],
                c='g',
                marker=marker)
    plt.show()
    plt.close()

    ldne = LDNE(copy.deepcopy(features), labels, 2, t=10)
    res = np.array(ldne.process())
    # print(res)

    plt.title('LDNE')
    plt.scatter(res[np.argwhere(labels == 0), 0],
                res[np.argwhere(labels == 0), 1],
                c='b',
                marker=marker)
    plt.scatter(res[np.argwhere(labels == 1), 0],
                res[np.argwhere(labels == 1), 1],
                c='g',
                marker=marker)
    plt.show()
    plt.close()