33import numpy as np
44
55
6- def tf_k_means_cluster_fixed (vectors , noofclusters ,max_iterations = 100 ,tolerance = 1e-4 ):
6+ def tf_k_means_clustering (vectors , noofclusters ,max_iterations = 100 ,tolerance = 1e-4 ):
77 """
88 Performs K-means clustering using a fixed and efficient vectorized approach, using Tensorflow 2.x
99
@@ -18,19 +18,19 @@ def tf_k_means_cluster_fixed(vectors, noofclusters,max_iterations = 100,toleranc
1818
1919 Example 1:
2020 >>>data2 = np.array([[0.0, 0.0], [0.1, 0.1], [10.0, 10.0]], dtype=np.float32)
21- >>>centroids2, assignments2 = tf_k_means_cluster_fixed (data2, 2)
21+ >>>centroids2, assignments2 = tf_k_means_clustering (data2, 2)
2222 >>>print(centroids2,assignments2)
2323 [[ 0.05 0.05]
2424 [10. 10. ]] [0 0 1]
2525
2626 Example 2 (Idential data points):
2727 >>>data_identical = np.array([[1.0, 1.0], [1.0, 1.0], [1.0, 1.0], [1.0, 1.0]], dtype=np.float32)
28- >>>centroids, assignments = tf_k_means_cluster_fixed (data_identical, 1)
28+ >>>centroids, assignments = tf_k_means_clustering (data_identical, 1)
2929 >>>print(centroids,assignments)
3030
3131 Example 3 (k>N):
3232 >>>data = np.array([[0.0, 0.0], [0.9, 0.9], [13.0, 15.0]], dtype=np.float32)
33- >>>centroids, assignments = tf_k_means_cluster_fixed (data, 5)
33+ >>>centroids, assignments = tf_k_means_clustering (data, 5)
3434 >>>print(centroids,assignments)
3535 """
3636
0 commit comments