code: def raw_score_to_proba(decision_scores, test_scores, method="linear"):
      """Utility function to convert raw scores to probability. The
      transformation can be either linear or using unify introduced in
      :cite:`kriegel2011interpreting`.
  
      Parameters
      ----------
      decision_scores : numpy array of shape (n_samples,)
          The outlier scores of the training data.
          The higher, the more abnormal. Outliers tend to have higher
          scores. This value is available once the detector is fitted.
  
      test_scores : numpy array of shape (n_samples,)
          The outlier scores of the test data to be converted.
          The higher, the more abnormal. Outliers tend to have higher
          scores. This value is available once the detector is fitted.
  
      method : str, optional (default='linear')
          The transformation method, either 'linear' or 'unify'
  
      Returns
      -------
      outlier_probability : numpy array of shape (n_samples,)
          For each observation, tells whether or not
          it should be considered as an outlier according to the
          fitted model. Return the outlier probability, ranging
          in [0,1].
      """
      probs = np.zeros([test_scores.shape[0], 2])
      if method == "linear":
          scaler = MinMaxScaler().fit(decision_scores.reshape(-1, 1))
          probs[:, 1] = (
              scaler.transform(test_scores.reshape(-1, 1))
              .ravel()
              .clip(0, 1)
          )
          probs[:, 0] = 1 - probs[:, 1]
          return probs
  
      elif method == "unify":
          # turn output into probability
          pre_erf_score = (
              test_scores - np.mean(decision_scores, axis=0)
          ) / (np.std(decision_scores) * np.sqrt(2))
          erf_score = erf(pre_erf_score)
          probs[:, 1] = erf_score.clip(0, 1).ravel()
          probs[:, 0] = 1 - probs[:, 1]
          return probs
      else:
          raise ValueError(
              method, "is not a valid probability conversion method"
          )
  
file_path: SUOD/suod/utils/utility.py
imports: import warnings
  import numpy
  import sklearn
  from pyod.models.abod import ABOD
  from pyod.models.hbos import HBOS
  from pyod.models.iforest import IForest
  from pyod.models.knn import KNN
  from pyod.models.lof import LOF
  from pyod.models.lscp import LSCP
  from pyod.models.mcd import MCD
  from pyod.models.ocsvm import OCSVM
  from pyod.models.pca import PCA
  from scipy.special import erf
  from sklearn.preprocessing import MinMaxScaler
label_desc: Use image node_id 3 for calling a global function with example usage: raw_score_to_proba(decision_scores, test_scores, method) and returns: probs, probs