Skip to content

skinning_clusters

skinning_clusters(W, D, T, k, l=2, num_clustering_features=10, return_centroids=False, return_simplex_features=False)

Skinning clusters.

Parameters:

Name Type Description Default
W numpy float array

n x b skinning weights

required
D numpy float array

b x 1 eigenvalue/weighing given to each skinning weight

required
T numpy int array

T x 4 tet geometry

required
k int

number of clusters

required
l int

power to raise D to

2
num_clustering_features int

number of features to use for clustering

10
return_centroids bool

whether to return the centroids of the clusters

False
return_simplex_features bool

whether to return the features averaged over each tet

False
Source code in src\fast_cody\skinning_clusters.py
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
def skinning_clusters(W, D, T, k, l=2, num_clustering_features=10,
                      return_centroids=False, return_simplex_features=False):
    """ Skinning clusters.

    Parameters
    ----------
    W : numpy float array
        n x b skinning weights
    D : numpy float array
        b x 1 eigenvalue/weighing given to each skinning weight
    T : numpy int array
        T x 4 tet geometry
    k : int
        number of clusters
    l : int
        power to raise D to
    num_clustering_features : int
        number of features to use for clustering
    return_centroids : bool
        whether to return the centroids of the clusters
    return_simplex_features : bool
        whether to return the features averaged over each tet
    """
    num_clustering_features = min(num_clustering_features, W.shape[1])
    # need to average the skinning weights over each tet
    assert(T.shape[1] == 4, "only tets implemented so far for clustering")

    Wt = average_onto_simplex(W, T)
    # Wt2 = Wt / np.power(D, 2)
    Wt = Wt / np.power(D, l)
    Wt = Wt[:, 0:num_clustering_features]
    kmeans = KMeans(n_clusters=k, random_state=0).fit(Wt)
    l = kmeans.labels_

    if return_simplex_features:
        return l, Wt
    if return_centroids == True:
        return l, kmeans.cluster_centers_
    else:
        return l