'''
Created on Feb 1, 2017

@author: Alexandre Day

    Purpose:
        Perform density clustering on gaussian mixture
'''

from fdc import FDC
from sklearn.datasets import make_blobs
from fdc import plotting
import pickle
import numpy as np

n_true_center = 15

np.random.seed(0)

print("------> Example with %i true cluster centers <-------"%n_true_center)

X, y = make_blobs(10000, 2, n_true_center) # Generating random gaussian mixture

model = FDC(noise_threshold=0.05, nh_size=40) # specifying density clustering parameters

model.fit(X) # performing the clustering

plotting.set_nice_font() # nicer plotting font !

plotting.summary_model(model, ytrue=y, show=True, savefile="result.png")
Пример #2
0
noise_threshold = 1.0

datasets = [noisy_circles, noisy_moons, varied, aniso, blobs, no_structure]
for i_dataset, dataset in enumerate(datasets):
    X, y = dataset
    # normalize dataset for easier parameter selection
    X = StandardScaler().fit_transform(X)

    # create clustering estimators

    model = FDC(noise_threshold=noise_threshold)

    s=time.time()

    model.fit(X)

    dt=time.time()-s

    n_center=len(model.idx_centers)

    plt.subplot(3,2,plot_num)
    plt.scatter(X[:, 0], X[:, 1], color=colors[model.cluster_label].tolist(), s=10,zorder=1)

    plt.text(.99, .07, ('%.2fs' % (dt)).lstrip('0'),
                 transform=plt.gca().transAxes, size=15,
                 horizontalalignment='right',zorder=2,
                bbox=dict(facecolor='white', edgecolor='black', boxstyle='round,pad=0.1')
                 )

    plot_num+=1