Beispiel #1
0
    def return_meshed_point_cloud(self, sourcepoint, points, simplify=0.1):
        #from sklearn.cluster import KMeans as kmeans
        from sklearn.cluster import MiniBatchKMeans as mbkmeans
        from scipy.spatial import Delaunay as delaunay
        nclusters = int(len(points) * simplify)
        #km = kmeans(n_clusters=nclusters, init='k-means++', n_init=10, max_iter=300, tol=0.0001, precompute_distances='auto', verbose=0, random_state=None, copy_x=True, n_jobs=1, algorithm='auto').fit(points)
        km = mbkmeans(n_clusters=nclusters,
                      init='k-means++',
                      n_init=10,
                      max_iter=300,
                      tol=0.001,
                      verbose=0,
                      random_state=None,
                      init_size=3 * nclusters).fit(points)
        self.clusters = km.cluster_centers_
        clusters = [list(item) for item in list(km.cluster_centers_)]
        if list(sourcepoint) in clusters:
            print('sourcepoint already in clusters')
        else:
            clusters = [list(sourcepoint)] + clusters

        print('got ' + str(len(clusters)) + ' clusters')
        tri_volume = delaunay(np.array(clusters),
                              furthest_site=False,
                              incremental=False,
                              qhull_options=None)
        return (tri_volume.points, tri_volume.simplices)
Beispiel #2
0
def kminicluster(data, numclusters, start=None):
	
	return mbkmeans(n_clusters=numclusters).fit(*format_data(data,start))
Beispiel #3
0
def kminicluster(data, numclusters, start=None):
    """Clusters the data using mini batch kmeans."""

    return mbkmeans(n_clusters=numclusters).fit(*format_data(data, start))
Beispiel #4
0
def kminicluster(data, numclusters, start=None, init='kmeans++'):

    return mbkmeans(n_clusters=numclusters,
                    init=init).fit(*format_data(data, start))
Beispiel #5
0
def kminicluster(data, numclusters, start=None,init='kmeans++'):
	
	return mbkmeans(n_clusters=numclusters,init=init).fit(*format_data(data,start))
Beispiel #6
0
def kminicluster(data, numclusters, start=None):
    """Clusters the data using mini batch kmeans."""
    
    return mbkmeans(n_clusters=numclusters).fit(*format_data(data,start))