code: def _get_radius(dataset, n_neighbors, sample_size=500, percentile=95):
      """
      Calculate the maximum allowed distance between points to be considered as neighbors
  
      Parameters
      ----------
      dataset : DataFrame
          Pool to sample from and calculate a radius
      n_neighbors : int
          Maximum number of neighbors considered per instance
      sample_size : int, optional
          Number of data points to sample from dataset, by default 500
      percentile : int, optional
          Percentile used to calculate the distance threshold, by default 95
  
      Returns
      -------
      radius : float
          Distance threshold
      """
      # Select 500 points max to sample
      size = min([dataset.shape[0], sample_size])
      # Randomly sample points from dataset
      sampled_instances = dataset[
          np.random.randint(0, dataset.shape[0], size), :
      ]
      # Define normalization vector
      mean_vector = np.array(dataset, dtype=np.float32).std(axis=0)
      # Initialize the similarity matrix
      similarity_distance = np.zeros((size, size))
      # Calculate pairwise distance between instances
      for i in range(size):
          for j in range(i, size):
              dist = _compute_distance(
                  sampled_instances[i],
                  sampled_instances[j],
                  mean_vector,
              )
              similarity_distance[i, j] = dist
              similarity_distance[j, i] = dist
      # Select top n_neighbors
      ordered_X = np.sort(similarity_distance)[:, 1 : n_neighbors + 1]
      # Select the value of the distance that captures XX% of all distances (percentile)
      return np.percentile(ordered_X.flatten(), percentile)
  
file_path: shapash/shapash/utils/explanation_metrics.py
imports: import numpy
  import pandas
  from sklearn.preprocessing import normalize
label_desc: Use image node_id 4 for calling a global function with example usage: _get_radius(dataset, n_neighbors, sample_size, percentile) and returns: np