2018-06-05 12:22:53 +00:00
|
|
|
from fog.clustering import *
|
2018-06-03 08:22:28 +00:00
|
|
|
from fog.metrics import jaccard_similarity
|
|
|
|
from Levenshtein import distance as levenshtein
|
|
|
|
|
2018-06-05 12:22:53 +00:00
|
|
|
data = [
|
|
|
|
'abc',
|
|
|
|
'bcd',
|
|
|
|
'cde',
|
|
|
|
'def',
|
|
|
|
'efg',
|
|
|
|
'fgh',
|
|
|
|
'ghi'
|
|
|
|
]
|
2018-06-03 08:22:28 +00:00
|
|
|
|
2018-06-05 12:22:53 +00:00
|
|
|
print('Pairwise leader')
|
|
|
|
for cluster in pairwise(data, distance=levenshtein, radius=2):
|
|
|
|
print(cluster)
|
2018-06-03 08:22:28 +00:00
|
|
|
|
2018-06-05 12:22:53 +00:00
|
|
|
print()
|
|
|
|
print('Pairwise fuzzy')
|
|
|
|
for cluster in pairwise_fuzzy_clusters(data, distance=levenshtein, radius=2):
|
|
|
|
print(cluster)
|
2018-06-03 08:22:28 +00:00
|
|
|
|
2018-06-05 12:22:53 +00:00
|
|
|
print()
|
|
|
|
print('Pairwise connected components')
|
|
|
|
for cluster in pairwise_connected_components(data, distance=levenshtein, radius=2):
|
|
|
|
print(cluster)
|
2018-06-07 14:53:00 +00:00
|
|
|
|
|
|
|
print()
|
|
|
|
print('VPTree')
|
|
|
|
for cluster in vp_tree(data, distance=levenshtein, radius=2):
|
|
|
|
print(cluster)
|