parameters: (self, X, y, classes=None, _refit=False, sample_weight=None)
return_statement: return self
docstring: Incremental fit on a batch of samples.
          This method is expected to be called several times consecutively on different chunks of a dataset so as toimplement out-of-core or online learning.
          This is especially useful when the whole dataset is too big to fit in memory at once.
          Parameters
          ----------
          X : array-like, shape (n_samples, n_features)
              Training vectors
          y : array-like, shape (n_samples,)
              Target values
          classes : array-like, shape (n_classes,), optional (default=None)
              List of all classes that can possibly appear in the y vector. Must be provided at the first call to partial_fit, can be omitted in subsequent calls.
          sample_weight : array-like, shape (n_samples,), optional (default=None)
              Weights applied to individual samples(1. for unweighted).
docstring_summary: Incremental fit on a batch of samples.
          This method is expected to be called several times consecutively on different chunks of a dataset so as toimplement out-of-core or online learning.
          This is especially useful when the whole dataset is too big to fit in memory at once.
          Parameters
          ----------
          X : array-like, shape (n_samples, n_features)
              Training vectors
          y : array-like, shape (n_samples,)
              Target values
          classes : array-like, shape (n_classes,), optional (default=None)
              List of all classes that can possibly appear in the y vector. Must be provided at the first call to partial_fit, can be omitted in subsequent calls.
          sample_weight : array-like, shape (n_samples,), optional (default=None)
              Weights applied to individual samples(1. for unweighted).
docstring_tokens: Incremental fit on a batch of samples . This method is expected to be called several times consecutively on different chunks of a dataset so as toimplement out - of - core or online learning . This is especially useful when the whole dataset is too big to fit in memory at once . Parameters ---------- X : array - like shape ( n_samples n_features ) Training vectors y : array - like shape ( n_samples ) Target values classes : array - like shape ( n_classes ) optional ( default = None ) List of all classes that can possibly appear in the y vector . Must be provided at the first call to partial_fit can be omitted in subsequent calls . sample_weight : array - like shape ( n_samples ) optional ( default = None ) Weights applied to individual samples ( 1 . for unweighted ) .
function: def _partial_fit(self, X, y, classes=None, _refit=False, sample_weight=None):
  
          """Incremental fit on a batch of samples.
          This method is expected to be called several times consecutively on different chunks of a dataset so as toimplement out-of-core or online learning.
          This is especially useful when the whole dataset is too big to fit in memory at once.
          Parameters
          ----------
          X : array-like, shape (n_samples, n_features)
              Training vectors
          y : array-like, shape (n_samples,)
              Target values
          classes : array-like, shape (n_classes,), optional (default=None)
              List of all classes that can possibly appear in the y vector. Must be provided at the first call to partial_fit, can be omitted in subsequent calls.
          sample_weight : array-like, shape (n_samples,), optional (default=None)
              Weights applied to individual samples(1. for unweighted).
          """
  
          # Checks if the provided epsilon, delta values can be spent without exceeding the accountant's budget.
          self.accountant.check(self.epsilon, 0)
  
          if sample_weight is not None:
              warn_unused_args("sample_weight")
  
          # Checks X and y for consistent length, enforces X to be 2D and y 1D.
          # By default, X is checked to be non-empty and containing only finite values.
          # Standard input checks are also applied to y, such as checking that y does not have np.nan or np.inf targets.
          X, y = check_X_y(X, y)
  
          if self.bounds is None:
              warnings.warn(
                  "Bounds have not been specified and will be calculated on the data provided. This will "
                  "result in additional privacy leakage. To ensure differential privacy and no additional "
                  "privacy leakage, specify bounds for each dimension.",
                  PrivacyLeakWarning,
              )
              self.bounds = (np.min(X, axis=0), np.max(X, axis=0))
  
          # Checks ``bounds`` is a list of tuples as (lower, upper), where lower<=upper and both numeric.
          # Checks for appropriate number of dimensions in ``bounds``.
          self.bounds = check_bounds(self.bounds, shape=X.shape[1])
          # Clips a 2-D array to given bounds.
          X = clip_to_bounds(X, self.bounds)
  
          self.epsilon_ = self.var_smoothing
  
          if _refit:
              self.classes_ = None
  
          # Checks if number of classes is assigned to ``n_classes`` for first call to partial_fit.
          if _check_partial_fit_first_call(self, classes):
              n_features = X.shape[1]
              n_classes = len(self.classes_)
              self.theta_ = np.zeros((n_classes, n_features))
              self.sigma_ = np.zeros((n_classes, n_features))
  
              self.class_count_ = np.zeros(n_classes, dtype=np.float64)
  
              if self.priors is not None:
                  priors = np.asarray(self.priors)
  
                  if len(priors) != n_classes:
                      raise ValueError("Number of priors must match number of classes.")
                  if not np.isclose(priors.sum(), 1.0):
                      raise ValueError("The sum of the priors should be 1.")
                  if (priors < 0).any():
                      raise ValueError("Priors must be non-negative.")
                  self.class_prior_ = priors
              else:
                  # Initialize the priors to zeros for each class
                  self.class_prior_ = np.zeros(len(self.classes_), dtype=np.float64)
          else:
              if X.shape[1] != self.theta_.shape[1]:
                  raise ValueError(
                      "Number of features %d does not match previous data %d."
                      % (X.shape[1], self.theta_.shape[1])
                  )
              # Put epsilon back in each time
              self.sigma_[:, :] -= self.epsilon_
  
          classes = self.classes_
  
          # Finds unique target values
          unique_y = np.unique(y)
          # Checks if each element of 1-D array is also present in the first instance of ``classes``
          unique_y_in_classes = np.in1d(unique_y, classes)
  
          if not np.all(unique_y_in_classes):
              raise ValueError(
                  "The target label(s) %s in y do not exist in the initial classes %s"
                  % (unique_y[~unique_y_in_classes], classes)
              )
  
          # Adds noise to number of training samples observed in each class
          noisy_class_counts = self._noisy_class_counts(y)
  
          # Updates mean, variance after adding noise to ``class_counts``
          for _i, y_i in enumerate(unique_y):
              i = classes.searchsorted(y_i)
              X_i = X[y == y_i, :]
  
              n_i = noisy_class_counts[_i]
  
              new_theta, new_sigma = self._update_mean_variance(
                  self.class_count_[i],
                  self.theta_[i, :],
                  self.sigma_[i, :],
                  X_i,
                  n_noisy=n_i,
              )
  
              self.theta_[i, :] = new_theta
              self.sigma_[i, :] = new_sigma
              self.class_count_[i] += n_i
  
          self.sigma_[:, :] += self.epsilon_
  
          # Update if only no priors is provided
          if self.priors is None:
              # Empirical prior, with sample_weight taken into account
              self.class_prior_ = self.class_count_ / self.class_count_.sum()
  
          # Instructs the accountant to spend given epsilon, delta privacy budget
          self.accountant.spend(self.epsilon, 0)
  
          return self
function_tokens: def _partial_fit ( self , X , y , classes = None , _refit = False , sample_weight = None ) : # Checks if the provided epsilon, delta values can be spent without exceeding the accountant's budget. self . accountant . check ( self . epsilon , 0 ) if sample_weight is not None : warn_unused_args ( "sample_weight" ) # Checks X and y for consistent length, enforces X to be 2D and y 1D. # By default, X is checked to be non-empty and containing only finite values. # Standard input checks are also applied to y, such as checking that y does not have np.nan or np.inf targets. X , y = check_X_y ( X , y ) if self . bounds is None : warnings . warn ( "Bounds have not been specified and will be calculated on the data provided. This will " "result in additional privacy leakage. To ensure differential privacy and no additional " "privacy leakage, specify bounds for each dimension." , PrivacyLeakWarning , ) self . bounds = ( np . min ( X , axis = 0 ) , np . max ( X , axis = 0 ) ) # Checks ``bounds`` is a list of tuples as (lower, upper), where lower<=upper and both numeric. # Checks for appropriate number of dimensions in ``bounds``. self . bounds = check_bounds ( self . bounds , shape = X . shape [ 1 ] ) # Clips a 2-D array to given bounds. X = clip_to_bounds ( X , self . bounds ) self . epsilon_ = self . var_smoothing if _refit : self . classes_ = None # Checks if number of classes is assigned to ``n_classes`` for first call to partial_fit. if _check_partial_fit_first_call ( self , classes ) : n_features = X . shape [ 1 ] n_classes = len ( self . classes_ ) self . theta_ = np . zeros ( ( n_classes , n_features ) ) self . sigma_ = np . zeros ( ( n_classes , n_features ) ) self . class_count_ = np . zeros ( n_classes , dtype = np . float64 ) if self . priors is not None : priors = np . asarray ( self . priors ) if len ( priors ) != n_classes : raise ValueError ( "Number of priors must match number of classes." ) if not np . isclose ( priors . sum ( ) , 1.0 ) : raise ValueError ( "The sum of the priors should be 1." ) if ( priors < 0 ) . any ( ) : raise ValueError ( "Priors must be non-negative." ) self . class_prior_ = priors else : # Initialize the priors to zeros for each class self . class_prior_ = np . zeros ( len ( self . classes_ ) , dtype = np . float64 ) else : if X . shape [ 1 ] != self . theta_ . shape [ 1 ] : raise ValueError ( "Number of features %d does not match previous data %d." % ( X . shape [ 1 ] , self . theta_ . shape [ 1 ] ) ) # Put epsilon back in each time self . sigma_ [ : , : ] -= self . epsilon_ classes = self . classes_ # Finds unique target values unique_y = np . unique ( y ) # Checks if each element of 1-D array is also present in the first instance of ``classes`` unique_y_in_classes = np . in1d ( unique_y , classes ) if not np . all ( unique_y_in_classes ) : raise ValueError ( "The target label(s) %s in y do not exist in the initial classes %s" % ( unique_y [ ~ unique_y_in_classes ] , classes ) ) # Adds noise to number of training samples observed in each class noisy_class_counts = self . _noisy_class_counts ( y ) # Updates mean, variance after adding noise to ``class_counts`` for _i , y_i in enumerate ( unique_y ) : i = classes . searchsorted ( y_i ) X_i = X [ y == y_i , : ] n_i = noisy_class_counts [ _i ] new_theta , new_sigma = self . _update_mean_variance ( self . class_count_ [ i ] , self . theta_ [ i , : ] , self . sigma_ [ i , : ] , X_i , n_noisy = n_i , ) self . theta_ [ i , : ] = new_theta self . sigma_ [ i , : ] = new_sigma self . class_count_ [ i ] += n_i self . sigma_ [ : , : ] += self . epsilon_ # Update if only no priors is provided if self . priors is None : # Empirical prior, with sample_weight taken into account self . class_prior_ = self . class_count_ / self . class_count_ . sum ( ) # Instructs the accountant to spend given epsilon, delta privacy budget self . accountant . spend ( self . epsilon , 0 ) return self