parameters: (self, X, y=None, sample_weight=None)
return_statement: return self
docstring: Fit estimator.
  
          Parameters
          ----------
          X : array-like or sparse matrix, shape (n_samples, n_features)
              The input samples. Use ``dtype=np.float32`` for maximum
              efficiency. Sparse matrices are also supported, use sparse
              ``csc_matrix`` for maximum efficiency.
  
          y : Ignored
              Not used, present for API consistency by convention.
  
          sample_weight : array-like of shape (n_samples,), default=None
              Sample weights. If None, then samples are equally weighted.
  
          Returns
          -------
          self : object
              Fitted estimator.
docstring_summary: Fit estimator.
docstring_tokens: Fit estimator .
function: def fit(self, X, y=None, sample_weight=None):
          """
          Fit estimator.
  
          Parameters
          ----------
          X : array-like or sparse matrix, shape (n_samples, n_features)
              The input samples. Use ``dtype=np.float32`` for maximum
              efficiency. Sparse matrices are also supported, use sparse
              ``csc_matrix`` for maximum efficiency.
  
          y : Ignored
              Not used, present for API consistency by convention.
  
          sample_weight : array-like of shape (n_samples,), default=None
              Sample weights. If None, then samples are equally weighted.
  
          Returns
          -------
          self : object
              Fitted estimator.
          """
          if self.behaviour != 'deprecated':
              if self.behaviour == 'new':
                  warn(
                      "'behaviour' is deprecated in 0.22 and will be removed "
                      "in 0.24. You should not pass or set this parameter.",
                      FutureWarning
                  )
              else:
                  raise NotImplementedError(
                      "The old behaviour of IsolationForest is not implemented "
                      "anymore. Remove the 'behaviour' parameter."
                  )
  
          X = check_array(X, accept_sparse=['csc'])
          if issparse(X):
              # Pre-sort indices to avoid that each individual tree of the
              # ensemble sorts the indices.
              X.sort_indices()
  
          rnd = check_random_state(self.random_state)
          y = rnd.uniform(size=X.shape[0])
  
          # ensure that max_sample is in [1, n_samples]:
          n_samples = X.shape[0]
  
          if isinstance(self.max_samples, str):
              if self.max_samples == 'auto':
                  max_samples = min(256, n_samples)
              else:
                  raise ValueError('max_samples (%s) is not supported.'
                                   'Valid choices are: "auto", int or'
                                   'float' % self.max_samples)
  
          elif isinstance(self.max_samples, numbers.Integral):
              if self.max_samples > n_samples:
                  warn("max_samples (%s) is greater than the "
                       "total number of samples (%s). max_samples "
                       "will be set to n_samples for estimation."
                       % (self.max_samples, n_samples))
                  max_samples = n_samples
              else:
                  max_samples = self.max_samples
          else:  # float
              if not 0. < self.max_samples <= 1.:
                  raise ValueError("max_samples must be in (0, 1], got %r"
                                   % self.max_samples)
              max_samples = int(self.max_samples * X.shape[0])
  
          self.max_samples_ = max_samples
          max_depth = int(np.ceil(np.log2(max(max_samples, 2))))
          super()._fit(X, y, max_samples,
                       max_depth=max_depth,
                       sample_weight=sample_weight)
  
          if self.contamination == "auto":
              # 0.5 plays a special role as described in the original paper.
              # we take the opposite as we consider the opposite of their score.
              self.offset_ = -0.5
              return self
  
          # else, define offset_ wrt contamination parameter
          self.offset_ = np.percentile(self.score_samples(X),
                                       100. * self.contamination)
  
          return self
function_tokens: def fit ( self , X , y = None , sample_weight = None ) : if self . behaviour != 'deprecated' : if self . behaviour == 'new' : warn ( "'behaviour' is deprecated in 0.22 and will be removed " "in 0.24. You should not pass or set this parameter." , FutureWarning ) else : raise NotImplementedError ( "The old behaviour of IsolationForest is not implemented " "anymore. Remove the 'behaviour' parameter." ) X = check_array ( X , accept_sparse = [ 'csc' ] ) if issparse ( X ) : # Pre-sort indices to avoid that each individual tree of the # ensemble sorts the indices. X . sort_indices ( ) rnd = check_random_state ( self . random_state ) y = rnd . uniform ( size = X . shape [ 0 ] ) # ensure that max_sample is in [1, n_samples]: n_samples = X . shape [ 0 ] if isinstance ( self . max_samples , str ) : if self . max_samples == 'auto' : max_samples = min ( 256 , n_samples ) else : raise ValueError ( 'max_samples (%s) is not supported.' 'Valid choices are: "auto", int or' 'float' % self . max_samples ) elif isinstance ( self . max_samples , numbers . Integral ) : if self . max_samples > n_samples : warn ( "max_samples (%s) is greater than the " "total number of samples (%s). max_samples " "will be set to n_samples for estimation." % ( self . max_samples , n_samples ) ) max_samples = n_samples else : max_samples = self . max_samples else : # float if not 0. < self . max_samples <= 1. : raise ValueError ( "max_samples must be in (0, 1], got %r" % self . max_samples ) max_samples = int ( self . max_samples * X . shape [ 0 ] ) self . max_samples_ = max_samples max_depth = int ( np . ceil ( np . log2 ( max ( max_samples , 2 ) ) ) ) super ( ) . _fit ( X , y , max_samples , max_depth = max_depth , sample_weight = sample_weight ) if self . contamination == "auto" : # 0.5 plays a special role as described in the original paper. # we take the opposite as we consider the opposite of their score. self . offset_ = - 0.5 return self # else, define offset_ wrt contamination parameter self . offset_ = np . percentile ( self . score_samples ( X ) , 100. * self . contamination ) return self