class_docstr: Linear Method for Deviation-based Outlier Detection.
  
  LMDD employs the concept of the smoothing factor which
  indicates how much the dissimilarity can be reduced by
  removing a subset of elements from the data-set.
  Read more in the :cite:`arning1996linear`.
  
  Note: this implementation has minor modification to make it output scores
  instead of labels.
  
  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.
  
  n_iter : int, optional (default=50)
      Number of iterations where in each iteration,
      the process is repeated after randomizing the order of the input.
      Note that n_iter is a very important factor that affects the accuracy.
      The higher the better the accuracy and the longer the execution.
  
  dis_measure: str, optional (default='aad')
      Dissimilarity measure to be used in calculating the smoothing factor
      for points, options available:
  
      - 'aad': Average Absolute Deviation
      - 'var': Variance
      - 'iqr': Interquartile Range
  
  random_state : int, RandomState instance or None, optional (default=None)
      If int, random_state is the seed used by the random number generator;
      If RandomState instance, random_state is the random number generator;
      If None, the random number generator is the RandomState instance used
      by `np.random`.
  
  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_``.
class_docstr_tok: ["Linear","Method","for","Deviation-based","Outlier","Detection",".","LMDD","employs","the","concept","of","the","smoothing","factor","which","indicates","how","much","the","dissimilarity","can","be","reduced","by","removing","a","subset","of","elements","from","the","data-set",".","Read","more","in","the",":","cite",":","`","arning1996linear","`",".","Note",":","this","implementation","has","minor","modification","to","make","it","output","scores","instead","of","labels",".","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",".","n_iter",":","int",",","optional","(","default=50",")","Number","of","iterations","where","in","each","iteration",",","the","process","is","repeated","after","randomizing","the","order","of","the","input",".","Note","that","n_iter","is","a","very","important","factor","that","affects","the","accuracy",".","The","higher","the","better","the","accuracy","and","the","longer","the","execution",".","dis_measure",":","str",",","optional","(","default='aad","'",")","Dissimilarity","measure","to","be","used","in","calculating","the","smoothing","factor","for","points",",","options","available",":","-","'aad","'",":","Average","Absolute","Deviation","-","'var","'",":","Variance","-","'iqr","'",":","Interquartile","Range","random_state",":","int",",","RandomState","instance","or","None",",","optional","(","default=None",")","If","int",",","random_state","is","the","seed","used","by","the","random","number","generator",";","If","RandomState","instance",",","random_state","is","the","random","number","generator",";","If","None",",","the","random","number","generator","is","the","RandomState","instance","used","by","`","np.random","`",".","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: Internal function to calculate for Smoothing Factors of data points
  Repeated n_iter_ of times in randomized mode.
docstr_tok: ["Internal","function","to","calculate","for","Smoothing","Factors","of","data","points","Repeated","n_iter_","of","times","in","randomized","mode","."]
code: def __sf(self, X):
      """Internal function to calculate for Smoothing Factors of data points
      Repeated n_iter_ of times in randomized mode.
      """
      dis_ = np.zeros(shape=(X.shape[0],))
      card_ = np.zeros(shape=(X.shape[0],))
      # perform one process with the original input order
      itr_res = self.__dis(X)
      np.put(
          card_,
          X.shape[0] - sum([i > 0.0 for i in itr_res]),
          np.where(itr_res > 0.0),
      )
  
      # create a copy of random state to preserve original state for
      # future fits (if any)
      random_state = np.random.RandomState(
          seed=self.random_state_.get_state()[1][0]
      )
      indices = np.arange(X.shape[0])
      for _ in range(self.n_iter_):
          ind_ = indices
          random_state.shuffle(ind_)
          _x = X[indices]
          # get dissimilarity of this iteration and restore original order
          itr_res = self.__dis(_x)[np.argsort(ind_)]
          current_card = X.shape[0] - sum([i > 0.0 for i in itr_res])
          # compare with previous iteration to get the maximal dissimilarity
          for i, j in enumerate(itr_res):
              if j > dis_[i]:
                  dis_[i] = j
                  card_[i] = current_card
          # Increase random state seed by one to reorder input next iteration
          random_state.seed(random_state.get_state()[1][0] + 1)
  
      return np.multiply(dis_, card_)
  
file_path: pyod/pyod/models/lmdd.py
imports: from __future__ import division
  from __future__ import print_function
  import numpy
  from numba import njit
  from scipy import stats
  from sklearn.utils import check_array, check_random_state
  from pyod.utils import check_parameter
  from .base import BaseDetector
label_desc: Use image node_id 5 for calling the LMDD obj's underlying member method code with example usage: obj.__sf(X) and returns: np