parameters: (X, y, Xy, precompute, normalize, fit_intercept, copy)
return_statement: return X, y, X_offset, y_offset, X_scale, precompute, Xy
docstring: Aux function used at beginning of fit in linear models
docstring_summary: Aux function used at beginning of fit in linear models
docstring_tokens: Aux function used at beginning of fit in linear models
function: def _pre_fit(X, y, Xy, precompute, normalize, fit_intercept, copy):
      """Aux function used at beginning of fit in linear models"""
      n_samples, n_features = X.shape
  
      if sparse.isspmatrix(X):
          precompute = False
          X, y, X_offset, y_offset, X_scale = _preprocess_data(
              X, y, fit_intercept=fit_intercept, normalize=normalize,
              return_mean=True)
      else:
          # copy was done in fit if necessary
          X, y, X_offset, y_offset, X_scale = _preprocess_data(
              X, y, fit_intercept=fit_intercept, normalize=normalize, copy=copy)
      if hasattr(precompute, '__array__') and (
              fit_intercept and not np.allclose(X_offset, np.zeros(n_features)) or
              normalize and not np.allclose(X_scale, np.ones(n_features))):
          warnings.warn("Gram matrix was provided but X was centered"
                        " to fit intercept, "
                        "or X was normalized : recomputing Gram matrix.",
                        UserWarning)
          # recompute Gram
          precompute = 'auto'
          Xy = None
  
      # precompute if n_samples > n_features
      if isinstance(precompute, six.string_types) and precompute == 'auto':
          precompute = (n_samples > n_features)
  
      if precompute is True:
          # make sure that the 'precompute' array is contiguous.
          precompute = np.empty(shape=(n_features, n_features), dtype=X.dtype,
                                order='C')
          np.dot(X.T, X, out=precompute)
  
      if not hasattr(precompute, '__array__'):
          Xy = None  # cannot use Xy if precompute is not Gram
  
      if hasattr(precompute, '__array__') and Xy is None:
          common_dtype = np.find_common_type([X.dtype, y.dtype], [])
          if y.ndim == 1:
              # Xy is 1d, make sure it is contiguous.
              Xy = np.empty(shape=n_features, dtype=common_dtype, order='C')
              np.dot(X.T, y, out=Xy)
          else:
              # Make sure that Xy is always F contiguous even if X or y are not
              # contiguous: the goal is to make it fast to extract the data for a
              # specific target.
              n_targets = y.shape[1]
              Xy = np.empty(shape=(n_features, n_targets), dtype=common_dtype,
                            order='F')
              np.dot(y.T, X, out=Xy.T)
  
      return X, y, X_offset, y_offset, X_scale, precompute, Xy
function_tokens: def _pre_fit ( X , y , Xy , precompute , normalize , fit_intercept , copy ) : n_samples , n_features = X . shape if sparse . isspmatrix ( X ) : precompute = False X , y , X_offset , y_offset , X_scale = _preprocess_data ( X , y , fit_intercept = fit_intercept , normalize = normalize , return_mean = True ) else : # copy was done in fit if necessary X , y , X_offset , y_offset , X_scale = _preprocess_data ( X , y , fit_intercept = fit_intercept , normalize = normalize , copy = copy ) if hasattr ( precompute , '__array__' ) and ( fit_intercept and not np . allclose ( X_offset , np . zeros ( n_features ) ) or normalize and not np . allclose ( X_scale , np . ones ( n_features ) ) ) : warnings . warn ( "Gram matrix was provided but X was centered" " to fit intercept, " "or X was normalized : recomputing Gram matrix." , UserWarning ) # recompute Gram precompute = 'auto' Xy = None # precompute if n_samples > n_features if isinstance ( precompute , six . string_types ) and precompute == 'auto' : precompute = ( n_samples > n_features ) if precompute is True : # make sure that the 'precompute' array is contiguous. precompute = np . empty ( shape = ( n_features , n_features ) , dtype = X . dtype , order = 'C' ) np . dot ( X . T , X , out = precompute ) if not hasattr ( precompute , '__array__' ) : Xy = None # cannot use Xy if precompute is not Gram if hasattr ( precompute , '__array__' ) and Xy is None : common_dtype = np . find_common_type ( [ X . dtype , y . dtype ] , [ ] ) if y . ndim == 1 : # Xy is 1d, make sure it is contiguous. Xy = np . empty ( shape = n_features , dtype = common_dtype , order = 'C' ) np . dot ( X . T , y , out = Xy ) else : # Make sure that Xy is always F contiguous even if X or y are not # contiguous: the goal is to make it fast to extract the data for a # specific target. n_targets = y . shape [ 1 ] Xy = np . empty ( shape = ( n_features , n_targets ) , dtype = common_dtype , order = 'F' ) np . dot ( y . T , X , out = Xy . T ) return X , y , X_offset , y_offset , X_scale , precompute , Xy