parameters: (X, y, indices, fit_intercept)
return_statement: return weights
docstring: Least Squares Estimator for TheilSenRegressor class.
  
      This function calculates the least squares method on a subset of rows of X
      and y defined by the indices array. Optionally, an intercept column is
      added if intercept is set to true.
  
      Parameters
      ----------
      X : array, shape = [n_samples, n_features]
          Design matrix, where n_samples is the number of samples and
          n_features is the number of features.
  
      y : array, shape = [n_samples]
          Target vector, where n_samples is the number of samples.
  
      indices : array, shape = [n_subpopulation, n_subsamples]
          Indices of all subsamples with respect to the chosen subpopulation.
  
      fit_intercept : bool
          Fit intercept or not.
  
      Returns
      -------
      weights : array, shape = [n_subpopulation, n_features + intercept]
          Solution matrix of n_subpopulation solved least square problems.
docstring_summary: Least Squares Estimator for TheilSenRegressor class.
docstring_tokens: Least Squares Estimator for TheilSenRegressor class .
function: def _lstsq(X, y, indices, fit_intercept):
      """Least Squares Estimator for TheilSenRegressor class.
  
      This function calculates the least squares method on a subset of rows of X
      and y defined by the indices array. Optionally, an intercept column is
      added if intercept is set to true.
  
      Parameters
      ----------
      X : array, shape = [n_samples, n_features]
          Design matrix, where n_samples is the number of samples and
          n_features is the number of features.
  
      y : array, shape = [n_samples]
          Target vector, where n_samples is the number of samples.
  
      indices : array, shape = [n_subpopulation, n_subsamples]
          Indices of all subsamples with respect to the chosen subpopulation.
  
      fit_intercept : bool
          Fit intercept or not.
  
      Returns
      -------
      weights : array, shape = [n_subpopulation, n_features + intercept]
          Solution matrix of n_subpopulation solved least square problems.
      """
      fit_intercept = int(fit_intercept)
      n_features = X.shape[1] + fit_intercept
      n_subsamples = indices.shape[1]
      weights = np.empty((indices.shape[0], n_features))
      X_subpopulation = np.ones((n_subsamples, n_features))
      # gelss need to pad y_subpopulation to be of the max dim of X_subpopulation
      y_subpopulation = np.zeros((max(n_subsamples, n_features)))
      lstsq, = get_lapack_funcs(('gelss',), (X_subpopulation, y_subpopulation))
  
      for index, subset in enumerate(indices):
          X_subpopulation[:, fit_intercept:] = X[subset, :]
          y_subpopulation[:n_subsamples] = y[subset]
          weights[index] = lstsq(X_subpopulation,
                                 y_subpopulation)[1][:n_features]
  
      return weights
function_tokens: def _lstsq ( X , y , indices , fit_intercept ) : fit_intercept = int ( fit_intercept ) n_features = X . shape [ 1 ] + fit_intercept n_subsamples = indices . shape [ 1 ] weights = np . empty ( ( indices . shape [ 0 ] , n_features ) ) X_subpopulation = np . ones ( ( n_subsamples , n_features ) ) # gelss need to pad y_subpopulation to be of the max dim of X_subpopulation y_subpopulation = np . zeros ( ( max ( n_subsamples , n_features ) ) ) lstsq , = get_lapack_funcs ( ( 'gelss' , ) , ( X_subpopulation , y_subpopulation ) ) for index , subset in enumerate ( indices ) : X_subpopulation [ : , fit_intercept : ] = X [ subset , : ] y_subpopulation [ : n_subsamples ] = y [ subset ] weights [ index ] = lstsq ( X_subpopulation , y_subpopulation ) [ 1 ] [ : n_features ] return weights