class_docstr: Stochastic Outlier Selection.
  
  SOS employs the concept of affinity to quantify
  the relationship from one data point to another data point. Affinity is 
  proportional to the similarity between two data points. So, a data point 
  has little affinity with a dissimilar data point. A data point is 
  selected as an outlier when all the other data points have insufficient
  affinity with it.
  Read more in the :cite:`janssens2012stochastic`.
  
  Parameters
  ----------
  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.
  
  perplexity : float, optional (default=4.5)
      A smooth measure of the effective number of neighbours. The perplexity
      parameter is similar to the parameter `k` in kNN algorithm (the number
      of nearest neighbors). The range of perplexity can be any real number
      between 1 and n-1, where `n` is the number of samples.
  
  metric: str, default 'euclidean'
      Metric used for the distance computation. Any metric from
      scipy.spatial.distance can be used.
  
      Valid values for metric are:
  
      - 'euclidean'
      - from scipy.spatial.distance: ['braycurtis', 'canberra',
        'chebyshev', 'correlation', 'dice', 'hamming', 'jaccard',
        'kulsinski', 'mahalanobis', 'matching', 'minkowski',
        'rogerstanimoto', 'russellrao', 'seuclidean', 'sokalmichener',
        'sokalsneath', 'sqeuclidean', 'yule']
  
      See the documentation for scipy.spatial.distance for details on these
      metrics:
      http://docs.scipy.org/doc/scipy/reference/spatial.distance.html
  
  eps : float, optional (default = 1e-5)
      Tolerance threshold for floating point errors.
      
  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_``.
      
      
  Examples
  --------
  >>> from pyod.models.sos import SOS
  >>> from pyod.utils.data import generate_data
  >>> n_train = 50
  >>> n_test = 50
  >>> contamination = 0.1
  >>> X_train, y_train, X_test, y_test = generate_data(
  ...     n_train=n_train, n_test=n_test,
  ...     contamination=contamination, random_state=42)
  >>>
  >>> clf = SOS()
  >>> clf.fit(X_train)
  SOS(contamination=0.1, eps=1e-05, metric='euclidean', perplexity=4.5)
class_docstr_tok: ["Stochastic","Outlier","Selection",".","SOS","employs","the","concept","of","affinity","to","quantify","the","relationship","from","one","data","point","to","another","data","point",".","Affinity","is","proportional","to","the","similarity","between","two","data","points",".","So",",","a","data","point","has","little","affinity","with","a","dissimilar","data","point",".","A","data","point","is","selected","as","an","outlier","when","all","the","other","data","points","have","insufficient","affinity","with","it",".","Read","more","in","the",":","cite",":","`","janssens2012stochastic","`",".","Parameters","--","--","--","--","--","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",".","perplexity",":","float",",","optional","(","default=4.5",")","A","smooth","measure","of","the","effective","number","of","neighbours",".","The","perplexity","parameter","is","similar","to","the","parameter","`","k","`","in","kNN","algorithm","(","the","number","of","nearest","neighbors",")",".","The","range","of","perplexity","can","be","any","real","number","between","1","and","n-1",",","where","`","n","`","is","the","number","of","samples",".","metric",":","str",",","default","'euclidean'","Metric","used","for","the","distance","computation",".","Any","metric","from","scipy.spatial.distance","can","be","used",".","Valid","values","for","metric","are",":","-","'euclidean'","-","from","scipy.spatial.distance",":","[","'braycurtis","'",",","'canberra","'",",","'chebyshev","'",",","'correlation","'",",","'dice","'",",","'hamming","'",",","'jaccard","'",",","'kulsinski","'",",","'mahalanobis","'",",","'matching","'",",","'minkowski","'",",","'rogerstanimoto","'",",","'russellrao","'",",","'seuclidean","'",",","'sokalmichener","'",",","'sokalsneath","'",",","'sqeuclidean","'",",","'yule","'","]","See","the","documentation","for","scipy.spatial.distance","for","details","on","these","metrics",":","http",":","\/\/docs.scipy.org\/doc\/scipy\/reference\/spatial.distance.html","eps",":","float",",","optional","(","default","=","1e-5",")","Tolerance","threshold","for","floating","point","errors",".","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_","``",".","Examples","--","--","--","--",">",">",">","from","pyod.models.sos","import","SOS",">",">",">","from","pyod.utils.data","import","generate_data",">",">",">","n_train","=","50",">",">",">","n_test","=","50",">",">",">","contamination","=","0.1",">",">",">","X_train",",","y_train",",","X_test",",","y_test","=","generate_data","(","...","n_train=n_train",",","n_test=n_test",",","...","contamination=contamination",",","random_state=42",")",">",">",">",">",">",">","clf","=","SOS","(",")",">",">",">","clf.fit","(","X_train",")","SOS","(","contamination=0.1",",","eps=1e-05",",","metric='euclidean","'",",","perplexity=4.5",")"]
docstr: Computes the binding probabilities of a given affinity
  matrix.
  
  Parameters
  ----------
  A : array, shape (n_samples, )
      The affinities matrix.
      
  Returns
  -------
  B : array, shape (n_samples, )
      Returns the matrix of binding probabilities.       
docstr_tok: ["Computes","the","binding","probabilities","of","a","given","affinity","matrix",".","Parameters","--","--","--","--","--","A",":","array",",","shape","(","n_samples",",",")","The","affinities","matrix",".","Returns","--","--","--","-","B",":","array",",","shape","(","n_samples",",",")","Returns","the","matrix","of","binding","probabilities","."]
code: def _a2b(self, A):
      """Computes the binding probabilities of a given affinity
      matrix.
  
      Parameters
      ----------
      A : array, shape (n_samples, )
          The affinities matrix.
  
      Returns
      -------
      B : array, shape (n_samples, )
          Returns the matrix of binding probabilities.
      """
  
      B = A / A.sum(axis=1)[:, np.newaxis]
      return B
  
file_path: pyod/pyod/models/sos.py
imports: from __future__ import division
  from __future__ import print_function
  import numpy
  from numba import njit
  from sklearn.utils import check_array
  from sklearn.utils.validation import check_is_fitted
  from .base import BaseDetector
label_desc: Use image node_id 4 for calling the SOS obj's underlying member method code with example usage: obj._a2b(A) and returns: B