Another kind of testing #507
-
First of all, I want to thank the author of the package for his great work. I have a medical imaging dataset, where each image belongs to a patient. Each patient has at least 3/4 images inside the dataset. Hence, there isn't a fixed number of classes. The method I'm currently using to test my algorithms is described as follows:
The question is: there is a way to replicate this behavior with the Thank you in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Since you're already computing all the embeddings, you can use from pytorch_metric_learning.utils.accuracy_calculator import AccuracyCalculator
ac = AccuracyCalculator(exclude=("AMI", "NMI"))
accuracies = ac.get_accuracy(emb, emb, labels, labels, embeddings_come_from_same_source=True)
print(accuracies) The knn computation uses faiss. If you don't want to install faiss, you can try this: from pytorch_metric_learning.distances import LpDistance
from pytorch_metric_learning.utils.inference import CustomKNN
distance = LpDistance() #L2 normalized distance
knn_func = CustomKNN(distance)
ac = AccuracyCalculator(exclude=("AMI", "NMI"), knn_func=knn_func) |
Beta Was this translation helpful? Give feedback.
Since you're already computing all the embeddings, you can use
AccuracyCalculator
:The knn computation uses faiss. If you don't want to install faiss, you can try this: