crossCosineSimilarity#
- nvmolkit.similarity.crossCosineSimilarity(
- fingerprint_group_one: AsyncGpuResult | Tensor | ndarray,
- fingerprint_group_two: AsyncGpuResult | Tensor | ndarray | None = None,
- stream: Stream | None = None,
Returns the Cosine similarity between two sets of fingerprints.
Expects fingerprints generated by nvMolKit, a torch tensor, or a numpy array, with the leading dimension corresponding to the number of fingerprints, and the second dimension representing the packed fingerprint bitfield. CPU tensors and NumPy arrays are copied to CUDA.
The special case of fingerprint_group_1 as a 1 x n_bits tensor is equivalent to RDKit’s BulkCosineSimilarity.
- Parameters:
fingerprint_group_one – A torch Tensor, numpy.ndarray, or AsyncGpuResult computed from nvMolKit fingerprints
fingerprint_group_two – A torch Tensor, numpy.ndarray, or AsyncGpuResult computed from nvMolKit fingerprints, or None for all-to-all similarity within fingerprint_group_one.
stream – CUDA stream to use. If None, uses the current stream.
- Returns:
An AsyncGpuResult object containing the Cosine similarities, with index [i, j] corresponding to the similarity between fingerprint i in fingerprint_group_one and fingerprint j in fingerprint_group_two.