We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b177389 commit 8a5e59cCopy full SHA for 8a5e59c
python-scipy-cluster-optimize/cluster_sms_spam.py
@@ -20,11 +20,9 @@
20
codebook, _ = kmeans(whitened_counts, 3)
21
codes, _ = vq(whitened_counts, codebook)
22
23
-possible_codes = {0, 1, 2}
24
-unique_codes, code_indices = np.unique(codes, return_index=True)
25
-ham_code = unique_codes[np.argmin(code_indices)]
26
-spam_code = unique_codes[np.argmax(code_indices)]
27
-unknown_code = list(possible_codes ^ set((ham_code, spam_code)))[0]
+ham_code = codes[0]
+spam_code = codes[-1]
+unknown_code = list(set(range(3)) ^ set((ham_code, spam_code)))[0]
28
29
print("definitely ham:", unique_counts[codes == ham_code][-1])
30
print("definitely spam:", unique_counts[codes == spam_code][-1])
0 commit comments