class_docstr: Connectivity-Based Outlier Factor (COF) COF uses the ratio of average
  chaining distance of data point and the average of average chaining
  distance of k nearest neighbor of the data point, as the outlier score
  for observations.
  
  See :cite:`tang2002enhancing` for details.
  
  Two version of COF are supported:
  
  - Fast COF: computes the entire pairwise distance matrix at the cost of a
    O(n^2) memory requirement.
  - Memory efficient COF: calculates pairwise distances incrementally.
    Use this implementation when it is not feasible to fit the n-by-n 
    distance in memory. This leads to a linear overhead because many 
    distances will have to be recalculated.
  
  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_neighbors : int, optional (default=20)
      Number of neighbors to use by default for k neighbors queries.
      Note that n_neighbors should be less than the number of samples.
      If n_neighbors is larger than the number of samples provided,
      all samples will be used.
      
  method : string, optional (default='fast')
      Valid values for method are:
          
      - 'fast' Fast COF, computes the full pairwise distance matrix up front.
      - 'memory' Memory-efficient COF, computes pairwise distances only when
        needed at the cost of computational speed.
  
  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_``.
  
  n_neighbors_: int
      Number of neighbors to use by default for k neighbors queries.
class_docstr_tok: ["Connectivity-Based","Outlier","Factor","(","COF",")","COF","uses","the","ratio","of","average","chaining","distance","of","data","point","and","the","average","of","average","chaining","distance","of","k","nearest","neighbor","of","the","data","point",",","as","the","outlier","score","for","observations",".","See",":","cite",":","`","tang2002enhancing","`","for","details",".","Two","version","of","COF","are","supported",":","-","Fast","COF",":","computes","the","entire","pairwise","distance","matrix","at","the","cost","of","a","O","(","n^2",")","memory","requirement",".","-","Memory","efficient","COF",":","calculates","pairwise","distances","incrementally",".","Use","this","implementation","when","it","is","not","feasible","to","fit","the","n-by-n","distance","in","memory",".","This","leads","to","a","linear","overhead","because","many","distances","will","have","to","be","recalculated",".","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_neighbors",":","int",",","optional","(","default=20",")","Number","of","neighbors","to","use","by","default","for","k","neighbors","queries",".","Note","that","n_neighbors","should","be","less","than","the","number","of","samples",".","If","n_neighbors","is","larger","than","the","number","of","samples","provided",",","all","samples","will","be","used",".","method",":","string",",","optional","(","default='fast","'",")","Valid","values","for","method","are",":","-","'fast","'","Fast","COF",",","computes","the","full","pairwise","distance","matrix","up","front",".","-","'memory","'","Memory-efficient","COF",",","computes","pairwise","distances","only","when","needed","at","the","cost","of","computational","speed",".","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_","``",".","n_neighbors_",":","int","Number","of","neighbors","to","use","by","default","for","k","neighbors","queries","."]
code: def __init__(self, contamination=0.1, n_neighbors=20, method="fast"):
      super(COF, self).__init__(contamination=contamination)
      if isinstance(n_neighbors, int):
          check_parameter(n_neighbors, low=1, param_name="n_neighbors")
      else:
          raise TypeError(
              "n_neighbors should be int. Got %s" % type(n_neighbors)
          )
      self.n_neighbors = n_neighbors
      self.method = method
  
file_path: pyod/pyod/models/cof.py
imports: from __future__ import division
  from __future__ import print_function
  import warnings
  from operator import itemgetter
  import numpy
  from scipy.spatial import distance_matrix
  from scipy.spatial import minkowski_distance
  from sklearn.utils import check_array
  from .base import BaseDetector
  from ..utils.utility import check_parameter
label_desc: Use image node_id 1 to create a new COF object from inherited base classes: BaseDetector with example: obj = COF(contamination, n_neighbors, method)