code: def _fit_stage_componentwise(X, residuals, sample_weight, **fit_params):
      
      n_features = X.shape[1]
  
      base_learners = []
      error = numpy.empty(n_features)
      for component in range(n_features):
          learner = ComponentwiseLeastSquares(component).fit(X, residuals, sample_weight)
          l_pred = learner.predict(X)
          error[component] = squared_norm(residuals - l_pred)
          base_learners.append(learner)
  
      # TODO: could use bottleneck.nanargmin for speed
      best_component = numpy.nanargmin(error)
      best_learner = base_learners[best_component]
      return best_learner
docs: Fit component-wise weighted least squares model