FEA-Bench / testbed /embeddings-benchmark__mteb /tests /test_ClusteringEvaluator.py
hc99's picture
Add files using upload-large-folder tool
73cc8d2 verified
raw
history blame
632 Bytes
from __future__ import annotations
from typing import List
import numpy as np
from mteb.evaluation.evaluators import ClusteringEvaluator
class TestClusteringEvaluator:
def test_clustering_v_measure(self):
class Model:
def encode(self, sentences: List[str], batch_size=32) -> np.ndarray:
return np.eye(len(sentences))
model = Model()
sentences = ["dog walked home", "cat walked home", "robot walked to the park"]
clusterer = ClusteringEvaluator(sentences=sentences, labels=[1, 2, 3])
result = clusterer(model)
assert result == {"v_measure": 1.0}