class_docstr: General class for loss functions with raw_prediction = X @ coef + intercept.
  
  Note that raw_prediction is also known as linear predictor.
  
  The loss is the average of per sample losses and includes a term for L2
  regularization::
  
      loss = 1 / s_sum * sum_i s_i loss(y_i, X_i @ coef + intercept)
             + 1/2 * l2_reg_strength * ||coef||_2^2
  
  with sample weights s_i=1 if sample_weight=None and s_sum=sum_i s_i.
  
  Gradient and hessian, for simplicity without intercept, are::
  
      gradient = 1 / s_sum * X.T @ loss.gradient + l2_reg_strength * coef
      hessian = 1 / s_sum * X.T @ diag(loss.hessian) @ X
                + l2_reg_strength * identity
  
  Conventions:
      if fit_intercept:
          n_dof =  n_features + 1
      else:
          n_dof = n_features
  
      if base_loss.is_multiclass:
          coef.shape = (n_classes, n_dof) or ravelled (n_classes * n_dof,)
      else:
          coef.shape = (n_dof,)
  
      The intercept term is at the end of the coef array:
      if base_loss.is_multiclass:
          if coef.shape (n_classes, n_dof):
              intercept = coef[:, -1]
          if coef.shape (n_classes * n_dof,)
              intercept = coef[n_features::n_dof] = coef[(n_dof-1)::n_dof]
          intercept.shape = (n_classes,)
      else:
          intercept = coef[-1]
  
  Note: If coef has shape (n_classes * n_dof,), the 2d-array can be reconstructed as
  
      coef.reshape((n_classes, -1), order="F")
  
  The option order="F" makes coef[:, i] contiguous. This, in turn, makes the
  coefficients without intercept, coef[:, :-1], contiguous and speeds up
  matrix-vector computations.
  
  Note: If the average loss per sample is wanted instead of the sum of the loss per
  sample, one can simply use a rescaled sample_weight such that
  sum(sample_weight) = 1.
  
  Parameters
  ----------
  base_loss : instance of class BaseLoss from sklearn._loss.
  fit_intercept : bool
docstr: Helper function to get coefficients, intercept and raw_prediction.
  
  Parameters
  ----------
  coef : ndarray of shape (n_dof,), (n_classes, n_dof) or (n_classes * n_dof,)
      Coefficients of a linear model.
      If shape (n_classes * n_dof,), the classes of one feature are contiguous,
      i.e. one reconstructs the 2d-array via
      coef.reshape((n_classes, -1), order="F").
  X : {array-like, sparse matrix} of shape (n_samples, n_features)
      Training data.
  
  Returns
  -------
  weights : ndarray of shape (n_features,) or (n_classes, n_features)
      Coefficients without intercept term.
  intercept : float or ndarray of shape (n_classes,)
      Intercept terms.
  raw_prediction : ndarray of shape (n_samples,) or             (n_samples, n_classes)
docstr_tok: ["Helper","function","to","get","coefficients",",","intercept","and","raw_prediction",".","Parameters","--","--","--","--","--","coef",":","ndarray","of","shape","(","n_dof",",",")",",","(","n_classes",",","n_dof",")","or","(","n_classes","*","n_dof",",",")","Coefficients","of","a","linear","model",".","If","shape","(","n_classes","*","n_dof",",",")",",","the","classes","of","one","feature","are","contiguous",",","i.e",".","one","reconstructs","the","2d-array","via","coef.reshape","(","(","n_classes",",","-1",")",",","order=","''","F","''",")",".","X",":","{","array-like",",","sparse","matrix","}","of","shape","(","n_samples",",","n_features",")","Training","data",".","Returns","--","--","--","-","weights",":","ndarray","of","shape","(","n_features",",",")","or","(","n_classes",",","n_features",")","Coefficients","without","intercept","term",".","intercept",":","float","or","ndarray","of","shape","(","n_classes",",",")","Intercept","terms",".","raw_prediction",":","ndarray","of","shape","(","n_samples",",",")","or","(","n_samples",",","n_classes",")"]
code: def weight_intercept_raw(self, coef, X):
      """Helper function to get coefficients, intercept and raw_prediction.
  
          Parameters
          ----------
          coef : ndarray of shape (n_dof,), (n_classes, n_dof) or (n_classes * n_dof,)
              Coefficients of a linear model.
              If shape (n_classes * n_dof,), the classes of one feature are contiguous,
              i.e. one reconstructs the 2d-array via
              coef.reshape((n_classes, -1), order="F").
          X : {array-like, sparse matrix} of shape (n_samples, n_features)
              Training data.
  
          Returns
          -------
          weights : ndarray of shape (n_features,) or (n_classes, n_features)
              Coefficients without intercept term.
          intercept : float or ndarray of shape (n_classes,)
              Intercept terms.
          raw_prediction : ndarray of shape (n_samples,) or \
              (n_samples, n_classes)
          """
      weights, intercept = self.weight_intercept(coef)
  
      if not self.base_loss.is_multiclass:
          raw_prediction = X @ weights + intercept
      else:
          # weights has shape (n_classes, n_dof)
          raw_prediction = (
              X @ weights.T + intercept
          )  # ndarray, likely C-contiguous
  
      return weights, intercept, raw_prediction
  
file_path: scikit-learn/sklearn/linear_model/_linear_loss.py
imports: import numpy
  from scipy import sparse
  from ..utils.extmath import squared_norm
label_desc: Use image node_id 4 for calling the LinearModelLoss obj's underlying member method code with example usage: obj.weight_intercept_raw(coef, X) and returns: weights,  intercept,  raw_prediction