synthval.metrics.PRScores ========================= .. py:class:: synthval.metrics.PRScores(row_batch_size = 25000, col_batch_size = 50000, num_nearest_n = 3) Bases: :py:obj:`SimilarityMetric` A Similarity Metric class that computes the Precision and Recall scores between two distributions (real_dist and synth_dist). .. attribute:: row_batch_size Size of the row batches used when computing pairwise distances. This provides a trade-off between memory usage and performance (default: 25000). :type: int, optional .. attribute:: col_batch_size Size of the column batches used for computing pairwise distances (default: 50000). :type: int, optional .. attribute:: num_nearest_n Number of nearest neighbors used to estimate the manifold. The manifold is used for computing precision and recall (default: 2). :type: int, optional .. rubric:: References Tuomas Kynkäänniemi, Tero Karras, Samuli Laine, Jaakko Lehtinen, Timo Aila - Improved Precision and Recall Metric for Assessing Generative Models - Annual Conference on Neural Information Processing Systems, 2019. .. py:method:: calculate(real_dist_df, synth_dist_df) Compute Precision and Recall metrics between two distributions. :param real_dist_df: DataFrame containing samples from distribution real_dist. :type real_dist_df: pandas.DataFrame :param synth_dist_df: DataFrame containing samples from distribution synth_dist. :type synth_dist_df: pandas.DataFrame :returns: A numpy array containing the Precision and the Recall metrics between distribution real_dist and synth_dist. :rtype: numpy.ndarray .. py:method:: __compute_distances(row_features, col_features, col_batch_size) :staticmethod: Compute pairwise distances between row and column features using batches to optimize memory usage. :param row_features: Tensor of feature vectors representing the rows. :type row_features: torch.Tensor :param col_features: Tensor of feature vectors representing the columns. :type col_features: torch.Tensor :param col_batch_size: Size of the column batches for computing distances. :type col_batch_size: int :returns: **dist_batches** -- Tensor of pairwise distances. :rtype: torch.Tensor