MCPcopy Index your code
hub / github.com/clips/pattern / test_cluster

Method test_cluster

test/test_vector.py:508–522  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

506 print "pattern.vector.Model.distance()"
507
508 def test_cluster(self):
509 # Assert Model document clustering.
510 v1 = self.model.cluster(method=vector.KMEANS, k=10)
511 v2 = self.model.cluster(method=vector.HIERARCHICAL, k=1)
512 self.assertTrue(isinstance(v1, list) and len(v1) == 10)
513 self.assertTrue(isinstance(v2, vector.Cluster))
514 def _test_clustered_documents(cluster):
515 if self.model[0] in cluster:
516 self.assertTrue(self.model[1] in cluster \
517 and not self.model[2] in cluster)
518 if self.model[2] in cluster:
519 self.assertTrue(self.model[3] in cluster \
520 and not self.model[1] in cluster)
521 v2.traverse(_test_clustered_documents)
522 print "pattern.vector.Model.cluster()"
523
524 def test_centroid(self):
525 # Assert centroid of recursive Cluster.

Callers

nothing calls this directly

Calls 3

lenFunction · 0.85
clusterMethod · 0.80
traverseMethod · 0.45

Tested by

no test coverage detected