CR_config_options = [(False, 0), (False, 1), (True, 0), (True, 1)]

    for idx, (coreset, prun_level) in enumerate(CR_config_options):

        y = y_base
        print("Config., (coreset, pruning level): ", coreset, prun_level)
        if coreset == True:
            Xo, yo = X, y
            X, y, ind = cr.coreset_extractor(Xo, yo, k=int(0.7 * len(Xo)))

        cc = cr.cluster_context(X, y)
        gv = cr.gval(cc)
        rc = cr.refinement_context(X, y, cc, gv)

        if p_outliers:
            y, cc = cr.refine(X, y, cc, gv, rc, prun_level=prun_level)
        else:
            y, cc = cr.refine(X,
                              y,
                              cc,
                              gv,
                              rc,
                              0,
                              min_rdens=-0.9,
                              min_mass=0.001,
                              out_sens=0,
                              prun_level=prun_level)

        if coreset == True:
            gv = cr.gval(cc)
            rc = cr.refinement_context(X, y, cc, gv)
Esempio n. 2
0
        print("CluReAL:", a_name)

        def_m = 5
        def_e = distances[kni]
        def_x = 0.08
        algorithm = select_algorithm(a_name, def_m, def_e, int(dim_m * 0.05),
                                     def_x)
        y = algorithm.fit_predict(X)

        cc = cr.cluster_context(X, y)
        gv = cr.gval(cc)
        rc = cr.refinement_context(X, y, cc, gv)

        if p_outliers:
            y, cc = cr.refine(X, y, cc, gv, rc, 0)
        else:
            y, cc = cr.refine(X,
                              y,
                              cc,
                              gv,
                              rc,
                              0,
                              min_rdens=-0.9,
                              min_mass=0.001,
                              out_sens=0)

        gv = cr.gval(cc)
        S, CH, DB = cr.other_validations(X, y)
        AMI = adjusted_mutual_info_score(ygt, y)
Esempio n. 3
0
plt.subplot(2, 3, 2)
cmap = get_cmap(max(y + 2), 'tab20b')
plt.scatter(X[:, 0], X[:, 1], s=2, color=cmap(y + 1))
plt.title("Dataset after k-means clustering (k=10)")

# Extracting clustering metadata for the SK ideogram
cc = cr.cluster_context(X, y)
gv = cr.gval(cc)
rc = cr.refinement_context(X, y, cc, gv)

# Plotting the SK ideogram of the normal clustering
plt.subplot(2, 3, 5)
cr.draw_symbol(cc, gv, rc)

# Refining with CluReAL and updating metadata
y, cc = cr.refine(X, y, cc, gv, rc)
gv = cr.gval(cc)
rc = cr.refinement_context(X, y, cc, gv)

# Plotting the refined clustered data
plt.subplot(2, 3, 3)
cmap = get_cmap(max(y + 2), 'tab20b')
plt.scatter(X[:, 0], X[:, 1], s=2, color=cmap(y + 1))
plt.scatter(X[y == -1, 0], X[y == -1, 1], s=2, c='k')
plt.title("Dataset after k-means + CluReAL refinement")

# Plotting the SK ideogram of the normal clustering
plt.subplot(2, 3, 6)
cr.draw_symbol(cc, gv, rc)

plt.show()