-
-
Save ajhwb/429198befc4d163e301d8cc766ca53b7 to your computer and use it in GitHub Desktop.
test_list_closest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def test_list_closest(self, test_client: Client, test_dataset: Dataset): | |
| n_clusters = 10 | |
| clusterer = test_client.ClusterOps( | |
| alias="new_clustering", | |
| model=MiniBatchKMeans(n_clusters=n_clusters), | |
| ) | |
| clusterer.run( | |
| dataset_id=test_dataset.dataset_id, | |
| vector_fields=["sample_1_vector_"], | |
| ) | |
| cluster_ids = ["cluster-0", "cluster-6"] | |
| closests = clusterer.list_closest( | |
| dataset_id=test_dataset.dataset_id, | |
| vector_field="sample_1_vector_", | |
| cluster_ids=cluster_ids, | |
| select_fields=["_id"], | |
| )["results"] | |
| assert len(closests) == len(cluster_ids) | |
| clusterer = test_client.ClusterOps( | |
| alias="new_clustering", | |
| model="kmeans", | |
| n_clusters=n_clusters, | |
| ) | |
| clusterer.run( | |
| dataset_id=test_dataset.dataset_id, | |
| vector_fields=["sample_1_vector_"], | |
| ) | |
| closests = clusterer.list_closest( | |
| dataset_id=test_dataset.dataset_id, | |
| vector_field="sample_1_vector_", | |
| )["results"] | |
| assert len(closests) == n_clusters |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment