class_docstr: Subspace outlier detection (SOD) schema aims to detect outlier in
  varying subspaces of a high dimensional feature space. For each data
  object, SOD explores the axis-parallel subspace spanned by the data
  object's neighbors and determines how much the object deviates from the
  neighbors in this subspace.
  
  See :cite:`kriegel2009outlier` for details.
  
  Parameters
  ----------
  n_neighbors : int, optional (default=20)
      Number of neighbors to use by default for k neighbors queries.
  
  ref_set: int, optional (default=10)
      specifies the number of shared nearest neighbors to create the
      reference set. Note that ref_set must be smaller than n_neighbors.
  
  alpha: float in (0., 1.), optional (default=0.8)
         specifies the lower limit for selecting subspace.
         0.8 is set as default as suggested in the original paper.
  
  contamination : float in (0., 0.5), optional (default=0.1)
      The amount of contamination of the data set, i.e.
      the proportion of outliers in the data set. Used when fitting to
      define the threshold on the decision function.
  
  Attributes
  ----------
  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.
  
  threshold_ : float
      The threshold is based on ``contamination``. It is the
      ``n_samples * contamination`` most abnormal samples in
      ``decision_scores_``. The threshold is calculated for generating
      binary outlier labels.
  
  labels_ : int, either 0 or 1
      The binary labels of the training data. 0 stands for inliers
      and 1 for outliers/anomalies. It is generated by applying
      ``threshold_`` on ``decision_scores_``.
docstr: This function is called internally to perform subspace outlier 
  detection algorithm.
  
  Returns
  -------
  anomaly_scores : numpy array of shape (n_samples,)
      The anomaly score of the input samples.
docstr_tok: ["This","function","is","called","internally","to","perform","subspace","outlier","detection","algorithm",".","Returns","--","--","--","-","anomaly_scores",":","numpy","array","of","shape","(","n_samples",",",")","The","anomaly","score","of","the","input","samples","."]
code: def _sod(self, X):
      """This function is called internally to perform subspace outlier
      detection algorithm.
  
      Returns
      -------
      anomaly_scores : numpy array of shape (n_samples,)
          The anomaly score of the input samples.
      """
      ref_inds = self._snn(X)
      anomaly_scores = np.zeros(shape=(X.shape[0],))
      for i in range(X.shape[0]):
          obs = X[i]
          ref = X[ref_inds[i,],]
          means = np.mean(ref, axis=0)  # mean of each column
          # average squared distance of the reference to the mean
          var_total = (
              np.sum(np.sum(np.square(ref - means))) / self.ref_set
          )
          var_expect = self.alpha * var_total / X.shape[1]
          var_actual = np.var(ref, axis=0)  # variance of each attribute
          var_inds = [1 if (j < var_expect) else 0 for j in var_actual]
          rel_dim = np.sum(var_inds)
          if rel_dim != 0:
              anomaly_scores[i] = np.sqrt(
                  np.dot(var_inds, np.square(obs - means)) / rel_dim
              )
  
      return anomaly_scores
  
file_path: pyod/pyod/models/sod.py
imports: import numba
  import numpy
  from sklearn.neighbors import NearestNeighbors
  from sklearn.utils import check_array
  from .base import BaseDetector
  from ..utils.utility import check_parameter
label_desc: Use image node_id 5 for calling the SOD obj's underlying member method code with example usage: obj._sod(X) and returns: anomaly_scores