def draw_graph(datasets, n_clusters=2):
    plot_num = 1
    alg_names = []
    eps_list = []

    for eps in np.arange(0.1, 1, step=0.1):
        alg_names.append('DBScan eps=%.1f' % eps)
        eps_list.append(eps)

    a = np.arange(len(alg_names)*2)+1
    indices = np.hstack(a.reshape(len(alg_names), 2).T)

    elice_utils.draw_init()

    for dataset in datasets:
        y = dataset['0']
        X = np.array(dataset[['1', '2']])

        for alg_name, eps in zip(alg_names, eps_list):
            dbscan_result = run_DBScan(X, eps)

            elice_utils.draw_graph(X, dbscan_result, alg_name, plot_num, len(alg_names), indices)
            plot_num += 1

    print(elice_utils.show_graph())

    return dbscan_result
def draw_graph(datasets, n_clusters=2):

    # DB-scan 알고리즘에서 eps값이 변화함에 따라 같은 클러스터로 인식하는 범위가 달라지는 여부를 비교해볼 수 있다.
    # 예상대로 eps값이 커질수록 멀리 떨어진 부분을 같은 클러스터로 인식한다.
    plot_num = 1
    alg_names = []
    eps_list = []

    for eps in np.arange(0.1, 1, step=0.1):
        alg_names.append("DBScan eps=%.1f" % eps)
        eps_list.append(eps)

    a = np.arange(len(alg_names) * 2) + 1
    indices = np.hstack(a.reshape(len(alg_names), 2).T)

    elice_utils.draw_init()

    for dataset in datasets:

        temp = []
        for idx in dataset.index:
            # print(str(dataset['1'][idx]) +', '+str(dataset['2'][idx]))
            temp.append([dataset["1"][idx], dataset["2"][idx]])

        X = np.array(temp)

        for alg_name, eps in zip(alg_names, eps_list):
            dbscan_result = run_DBScan(X, eps)

            elice_utils.draw_graph(X, dbscan_result, alg_name, plot_num, len(alg_names), indices)
            plot_num += 1

    print(elice_utils.show_graph())

    return dbscan_result
def draw_graph(datasets, n_clusters=2):
    plot_num = 1
    alg_names = []
    eps_list = []

    for eps in np.arange(0.1, 1, step=0.1):
        alg_names.append('DBScan eps=%.1f' % eps)
        eps_list.append(eps)

    a = np.arange(len(alg_names) * 2) + 1
    indices = np.hstack(a.reshape(len(alg_names), 2).T)

    elice_utils.draw_init()

    for dataset in datasets:
        y = dataset['0']
        X = np.array(dataset[['1', '2']])

        for alg_name, eps in zip(alg_names, eps_list):
            dbscan_result = run_DBScan(X, eps)

            elice_utils.draw_graph(X, dbscan_result, alg_name, plot_num,
                                   len(alg_names), indices)
            plot_num += 1

    print(elice_utils.show_graph())

    return dbscan_result
def main():
    C = 1.0

    X, y = load_data()

    pca, X_pca = run_PCA(X, 2)
    lda, X_lda = run_LDA(X, y, 2)

    svc_linear_pca = run_linear_SVM(X_pca, y, C)
    svc_rbf_pca = run_rbf_SVM(X_pca, y, C)

    svc_linear_lda = run_linear_SVM(X_lda, y, C)
    svc_rbf_lda = run_rbf_SVM(X_lda, y, C)

    elice_utils.draw_graph(X_pca, X_lda, y, svc_linear_pca, svc_rbf_pca, svc_linear_lda, svc_rbf_lda)
    print(elice_utils.show_graph())
Beispiel #5
0
def main():
    C = 1.0

    X, y = load_data()

    pca, X_pca = run_PCA(X, 2)
    lda, X_lda = run_LDA(X, y, 2)

    svc_linear_pca = run_linear_SVM(X_pca, y, C)
    svc_rbf_pca = run_rbf_SVM(X_pca, y, C)

    svc_linear_lda = run_linear_SVM(X_lda, y, C)
    svc_rbf_lda = run_rbf_SVM(X_lda, y, C)

    elice_utils.draw_graph(X_pca, X_lda, y, svc_linear_pca, svc_rbf_pca, svc_linear_lda, svc_rbf_lda)
    print(elice_utils.show_graph())
Beispiel #6
0
def draw_graph(datasets, n_clusters=2, alg_name = 'KMeans'):
    plot_num = 1

    elice_utils.draw_init()

    for dataset in datasets:
        # 3


        kmeans_result = run_kmeans(X, n_clusters)

        elice_utils.draw_graph(X, kmeans_result, alg_name, plot_num)
        plot_num += 1

    print(elice_utils.show_graph())

    return kmeans_result
def draw_graph(datasets, n_clusters=2, alg_name='KMeans'):
    plot_num = 1

    elice_utils.draw_init()

    for dataset in datasets:
        y = dataset['0']
        X = np.array(dataset[['1', '2']])

        kmeans_result = run_kmeans(X, n_clusters)

        elice_utils.draw_graph(X, kmeans_result, alg_name, plot_num)
        plot_num += 1

    print(elice_utils.show_graph())

    return kmeans_result
Beispiel #8
0
def draw_graph(datasets, n_clusters=2, alg_name = 'KMeans'):
    plot_num = 1

    elice_utils.draw_init()

    for dataset in datasets:
        # 3
        y = dataset.ix[:,0]
        X = np.vstack((dataset.ix[:,1],dataset.ix[:,2])).T

        kmeans_result = run_kmeans(X, n_clusters)

        elice_utils.draw_graph(X, kmeans_result, alg_name, plot_num)
        plot_num += 1

    print(elice_utils.show_graph())

    return kmeans_result
Beispiel #9
0
def draw_graph(datasets, n_clusters=2, eps=0.2, alg_name = ['KMeans', 'DBScan']):
    plot_num = 1

    elice_utils.draw_init()

    for dataset in datasets:
        # 4
        X = np.vstack((dataset.ix[:,1],dataset.ix[:,2])).T
        kmeans_result = run_kmeans(X, n_clusters)
        dbscan_result = run_DBScan(X, eps)

        for name, algorithm in zip(alg_name, [kmeans_result, dbscan_result]):
            elice_utils.draw_graph(X, algorithm, name, plot_num)
            plot_num += 1

    print(elice_utils.show_graph())

    return dbscan_result
Beispiel #10
0
def draw_graph(datasets, n_clusters=2, eps=0.2, alg_name=['KMeans', 'DBScan']):
    plot_num = 1

    elice_utils.draw_init()

    for dataset in datasets:
        # 4
        X = np.vstack((dataset.ix[:, 1], dataset.ix[:, 2])).T
        kmeans_result = run_kmeans(X, n_clusters)
        dbscan_result = run_DBScan(X, eps)

        for name, algorithm in zip(alg_name, [kmeans_result, dbscan_result]):
            elice_utils.draw_graph(X, algorithm, name, plot_num)
            plot_num += 1

    print(elice_utils.show_graph())

    return dbscan_result
def draw_graph(datasets, n_clusters=2, alg_name = 'KMeans'):
    plot_num = 1

    elice_utils.draw_init()
    for dataset in datasets:
        # 3
        tmp_y = dataset.pop('0')
        y = np.array(tmp_y)
        
        tmp_X = dataset
        X = np.array(tmp_X)
        kmeans_result = run_kmeans(X, n_clusters)

        elice_utils.draw_graph(X, kmeans_result, alg_name, plot_num)
        plot_num += 1

    print(elice_utils.show_graph())

    return kmeans_result
Beispiel #12
0
def draw_graph(datasets, n_clusters=2, alg_name='KMeans'):
    plot_num = 1

    elice_utils.draw_init()
    for dataset in datasets:
        # 3
        tmp_y = dataset.pop('0')
        y = np.array(tmp_y)

        tmp_X = dataset
        X = np.array(tmp_X)
        kmeans_result = run_kmeans(X, n_clusters)

        elice_utils.draw_graph(X, kmeans_result, alg_name, plot_num)
        plot_num += 1

    print(elice_utils.show_graph())

    return kmeans_result
def draw_graph(datasets, n_clusters=2, eps=0.2, alg_name = ['KMeans', 'DBScan']):
    plot_num = 1

    elice_utils.draw_init()

    for dataset in datasets:
        y = dataset['0']
        X = np.array(dataset[['1', '2']])

        kmeans_result = run_kmeans(X, n_clusters)
        dbscan_result = run_DBScan(X, eps)

        for name, algorithm in zip(alg_name, [kmeans_result, dbscan_result]):
            elice_utils.draw_graph(X, algorithm, name, plot_num)
            plot_num += 1

    print(elice_utils.show_graph())

    return dbscan_result