class_docstr: Calculate trust score.
  
  Parameters
  ----------
  k_filter : int , default: 10
      Number of neighbors used during either kNN distance or probability filtering.
  alpha : float , default: 0.
      Fraction of instances to filter out to reduce impact of outliers.
  filter_type : str , default: distance_knn
      Filter method; either 'distance_knn' or 'probability_knn'
  leaf_size : int , default: 40
      Number of points at which to switch to brute-force. Affects speed and memory required to
      build trees. Memory to store the tree scales with n_samples / leaf_size.
  metric : str , default: euclidean
      Distance metric used for the tree. See sklearn's DistanceMetric class for a list of available
      metrics.
  dist_filter_type : str , default: point
      Use either the distance to the k-nearest point (dist_filter_type = 'point') or
      the average distance from the first to the k-nearest point in the data (dist_filter_type = 'mean').
class_docstr_tok: ["Calculate","trust","score",".","Parameters","--","--","--","--","--","k_filter",":","int",",","default",":","10","Number","of","neighbors","used","during","either","kNN","distance","or","probability","filtering",".","alpha",":","float",",","default",":","0",".","Fraction","of","instances","to","filter","out","to","reduce","impact","of","outliers",".","filter_type",":","str",",","default",":","distance_knn","Filter","method",";","either","'distance_knn","'","or","'probability_knn'","leaf_size",":","int",",","default",":","40","Number","of","points","at","which","to","switch","to","brute-force",".","Affects","speed","and","memory","required","to","build","trees",".","Memory","to","store","the","tree","scales","with","n_samples","\/","leaf_size",".","metric",":","str",",","default",":","euclidean","Distance","metric","used","for","the","tree",".","See","sklearn","'s","DistanceMetric","class","for","a","list","of","available","metrics",".","dist_filter_type",":","str",",","default",":","point","Use","either","the","distance","to","the","k-nearest","point","(","dist_filter_type","=","'point","'",")","or","the","average","distance","from","the","first","to","the","k-nearest","point","in","the","data","(","dist_filter_type","=","'mean","'",")","."]
docstr: Process confidence scores.
docstr_tok: ["Process","confidence","scores","."]
code: def process_confidence_scores(
      baseline_scores: np.ndarray, test_scores: np.ndarray
  ):
      """Process confidence scores."""
      # code to filter extreme confidence values
      filter_center_factor = 4
      filter_center_size = 40.0  # % of data
  
      baseline_confidence = baseline_scores
      if test_scores is None:
          test_confidence = baseline_scores
      else:
          test_confidence = test_scores
  
      center_size = max(
          np.nanpercentile(
              baseline_confidence, 50 + filter_center_size / 2
          ),
          np.nanpercentile(
              test_confidence, 50 + filter_center_size / 2
          ),
      ) - min(
          np.nanpercentile(
              baseline_confidence, 50 - filter_center_size / 2
          ),
          np.nanpercentile(
              test_confidence, 50 - filter_center_size / 2
          ),
      )
      max_median = max(
          np.nanmedian(baseline_confidence),
          np.nanmedian(test_confidence),
      )
      min_median = min(
          np.nanmedian(baseline_confidence),
          np.nanmedian(test_confidence),
      )
  
      upper_thresh = max_median + filter_center_factor * center_size
      lower_thresh = min_median - filter_center_factor * center_size
  
      baseline_confidence[
          (baseline_confidence > upper_thresh)
          | (baseline_confidence < lower_thresh)
      ] = np.nan
      test_confidence[
          (test_confidence > upper_thresh)
          | (test_confidence < lower_thresh)
      ] = np.nan
  
      baseline_confidence = baseline_confidence.astype(float)
      test_confidence = test_confidence.astype(float)
  
      if test_scores is None:
          test_confidence = None
  
      return baseline_confidence, test_confidence
  
file_path: deepchecks/deepchecks/utils/distribution/trust_score.py
imports: from typing import Tuple
  import numpy
  from sklearn.neighbors import KDTree, KNeighborsClassifier
  from deepchecks.utils.logger import get_logger
label_desc: Use image node_id 6 for calling the TrustScore obj's underlying member method code with example usage: obj.process_confidence_scores(baseline_scores, test_scores) and returns: baseline_confidence,  test_confidence