Skip to content

Commit aa55cba

Browse files
authored
fix: removed doctests for first PR
1 parent 7e2baa5 commit aa55cba

1 file changed

Lines changed: 0 additions & 26 deletions

File tree

dynamic_programming/k_means_clustering_tensorflow.py

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,6 @@
66
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
9-
10-
Parameters:
11-
vectors (list): A list of vectors.
12-
noofclusters (int): The number of clusters (k).
13-
max_iterations(int): maximum number of iterations or how many times the algorithm will refine its cluster assignments and centroid positions, until convergence.
14-
tolerance(int): defines a convergence criterion. The K-means algorithm stops when the centroids move less than this tolerance value between consecutive iterations.
15-
16-
(set same random seed in all examples for reproducibility)
17-
>>>tf.random.set_seed(42)
18-
19-
Example 1:
20-
>>>data2 = np.array([[0.0, 0.0], [0.1, 0.1], [10.0, 10.0]], dtype=np.float32)
21-
>>>centroids2, assignments2 = tf_k_means_clustering(data2, 2)
22-
>>>print(centroids2,assignments2)
23-
[[ 0.05 0.05]
24-
[10. 10. ]] [0 0 1]
25-
26-
Example 2 (Idential data points):
27-
>>>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_clustering(data_identical, 1)
29-
>>>print(centroids,assignments)
30-
31-
Example 3 (k>N):
32-
>>>data = np.array([[0.0, 0.0], [0.9, 0.9], [13.0, 15.0]], dtype=np.float32)
33-
>>>centroids, assignments = tf_k_means_clustering(data, 5)
34-
>>>print(centroids,assignments)
359
"""
3610

3711

0 commit comments

Comments
 (0)