class_docstr: Sparse Logistic regression scikit-learn estimator based on Celer solver.
  
  The optimization objective for sparse Logistic regression is::
  
  \sum_1^n_samples log(1 + e^{-y_i x_i^T w}) + 1. / C * ||w||_1
  
  The solvers use a working set strategy. To solve problems restricted to a
  subset of features, Celer uses coordinate descent while PN-Celer uses
  a Prox-Newton strategy (detailed in [1], Sec 5.2).
  
  Parameters
  ----------
  C : float, default=1.0
      Inverse of regularization strength; must be a positive float.
  
  penalty : 'l1'.
      Other penalties are not supported.
  
  solver : "celer" | "celer-pn", default="celer-pn"
      Algorithm to use in the optimization problem.
  
      - celer-pn uses working sets and prox-Newton solver on the working set.
      - celer uses working sets and coordinate descent
  
  tol : float, optional
      Stopping criterion for the optimization: the solver runs until the
      duality gap is smaller than ``tol * len(y) * log(2)`` or the
      maximum number of iteration is reached.
  
  fit_intercept : bool, optional (default=False)
      Whether or not to fit an intercept. Currently True is not supported.
  
  max_iter : int, optional
      The maximum number of iterations (subproblem definitions)
  
  verbose : bool or integer
      Amount of verbosity.
  
  max_epochs : int
      Maximum number of CD epochs on each subproblem.
  
  p0 : int
      First working set size.
  
  warm_start : bool, optional (default=False)
      When set to True, reuse the solution of the previous call to fit as
      initialization, otherwise, just erase the previous solution.
      Only False is supported so far.
  
  
  Attributes
  ----------
  
  classes_ : ndarray of shape (n_classes, )
      A list of class labels known to the classifier.
  
  coef_ : ndarray of shape (1, n_features) or (n_classes, n_features)
      Coefficient of the features in the decision function.
  
      `coef_` is of shape (1, n_features) when the given problem is binary.
  
  intercept_ :  ndarray of shape (1,) or (n_classes,)
      constant term in decision function. Not handled yet.
  
  n_iter_ : int
      Number of subproblems solved by Celer to reach the specified tolerance.
  
  Examples
  --------
  >>> from celer import LogisticRegression
  >>> clf = LogisticRegression(C=1.)
  >>> clf.fit([[0, 0], [1, 1], [2, 2]], [0, 1, 1])
  LogisticRegression(C=1.0, penalty='l1', tol=0.0001, fit_intercept=False,
  max_iter=50, verbose=False, max_epochs=50000, p0=10, warm_start=False)
  
  >>> print(clf.coef_)
  [[0.4001237  0.01949392]]
  
  See also
  --------
  celer_path
  
  References
  ----------
  .. [1] M. Massias, S. Vaiter, A. Gramfort, J. Salmon
     "Dual Extrapolation for Sparse Generalized Linear Models", JMLR 2020,
     https://arxiv.org/abs/1907.05830
class_docstr_tok: ["Sparse","Logistic","regression","scikit-learn","estimator","based","on","Celer","solver",".","The","optimization","objective","for","sparse","Logistic","regression","is",":",":","\\sum_1^n_samples","log","(","1","+","e^","{","-y_i","x_i^T","w","}",")","+","1",".","\/","C","*","||w||_1","The","solvers","use","a","working","set","strategy",".","To","solve","problems","restricted","to","a","subset","of","features",",","Celer","uses","coordinate","descent","while","PN-Celer","uses","a","Prox-Newton","strategy","(","detailed","in","[","1","]",",","Sec","5.2",")",".","Parameters","--","--","--","--","--","C",":","float",",","default=1.0","Inverse","of","regularization","strength",";","must","be","a","positive","float",".","penalty",":","'l1","'",".","Other","penalties","are","not","supported",".","solver",":","``","celer","''","|","``","celer-pn","''",",","default=","''","celer-pn","''","Algorithm","to","use","in","the","optimization","problem",".","-","celer-pn","uses","working","sets","and","prox-Newton","solver","on","the","working","set",".","-","celer","uses","working","sets","and","coordinate","descent","tol",":","float",",","optional","Stopping","criterion","for","the","optimization",":","the","solver","runs","until","the","duality","gap","is","smaller","than","``","tol","*","len","(","y",")","*","log","(","2",")","``","or","the","maximum","number","of","iteration","is","reached",".","fit_intercept",":","bool",",","optional","(","default=False",")","Whether","or","not","to","fit","an","intercept",".","Currently","True","is","not","supported",".","max_iter",":","int",",","optional","The","maximum","number","of","iterations","(","subproblem","definitions",")","verbose",":","bool","or","integer","Amount","of","verbosity",".","max_epochs",":","int","Maximum","number","of","CD","epochs","on","each","subproblem",".","p0",":","int","First","working","set","size",".","warm_start",":","bool",",","optional","(","default=False",")","When","set","to","True",",","reuse","the","solution","of","the","previous","call","to","fit","as","initialization",",","otherwise",",","just","erase","the","previous","solution",".","Only","False","is","supported","so","far",".","Attributes","--","--","--","--","--","classes_",":","ndarray","of","shape","(","n_classes",",",")","A","list","of","class","labels","known","to","the","classifier",".","coef_",":","ndarray","of","shape","(","1",",","n_features",")","or","(","n_classes",",","n_features",")","Coefficient","of","the","features","in","the","decision","function",".","`","coef_","`","is","of","shape","(","1",",","n_features",")","when","the","given","problem","is","binary",".","intercept_",":","ndarray","of","shape","(","1",",",")","or","(","n_classes",",",")","constant","term","in","decision","function",".","Not","handled","yet",".","n_iter_",":","int","Number","of","subproblems","solved","by","Celer","to","reach","the","specified","tolerance",".","Examples","--","--","--","--",">",">",">","from","celer","import","LogisticRegression",">",">",">","clf","=","LogisticRegression","(","C=1",".",")",">",">",">","clf.fit","(","[","[","0",",","0","]",",","[","1",",","1","]",",","[","2",",","2","]","]",",","[","0",",","1",",","1","]",")","LogisticRegression","(","C=1.0",",","penalty='l1","'",",","tol=0.0001",",","fit_intercept=False",",","max_iter=50",",","verbose=False",",","max_epochs=50000",",","p0=10",",","warm_start=False",")",">",">",">","print","(","clf.coef_",")","[","[","0.4001237","0.01949392","]","]","See","also","--","--","--","--","celer_path","References","--","--","--","--","--","..","[","1","]","M.","Massias",",","S.","Vaiter",",","A.","Gramfort",",","J.","Salmon","``","Dual","Extrapolation","for","Sparse","Generalized","Linear","Models","''",",","JMLR","2020",",","https",":","\/\/arxiv.org\/abs\/1907.05830"]
docstr: Fit the model according to the given training data.
  
  Parameters
  ----------
  X : {array-like, sparse matrix} of shape (n_samples, n_features)
      Training vector, where n_samples is the number of samples and
      n_features is the number of features.
  
  y : array-like of shape (n_samples,)
      Target vector relative to X.
  
  Returns
  -------
  self
      Fitted estimator.
code: def fit(self, X, y):
      """
      Fit the model according to the given training data.
  
      Parameters
      ----------
      X : {array-like, sparse matrix} of shape (n_samples, n_features)
          Training vector, where n_samples is the number of samples and
          n_features is the number of features.
  
      y : array-like of shape (n_samples,)
          Target vector relative to X.
  
      Returns
      -------
      self
          Fitted estimator.
      """
      # TODO handle normalization, centering
      # TODO intercept
      if self.fit_intercept:
          raise NotImplementedError(
              "Fitting an intercept is not implement yet"
          )
      # TODO support warm start
      if self.penalty != "l1":
          raise NotImplementedError(
              "Only L1 penalty is supported, got %s" % self.penalty
          )
  
      if not isinstance(self.C, numbers.Number) or self.C <= 0:
          raise ValueError(
              "Penalty term must be positive; got (C=%r)" % self.C
          )
      # below are copy pasted excerpts from sklearn.linear_model._logistic
      X, y = check_X_y(X, y, accept_sparse="csr", order="C")
      check_classification_targets(y)
      enc = LabelEncoder()
      y_ind = enc.fit_transform(y)
      self.classes_ = enc.classes_
      n_classes = len(enc.classes_)
  
      if not hasattr(self, "n_features_in_"):
          self.n_features_in_ = X.shape[1]
  
      if n_classes <= 2:
          coefs = self.path(
              X, 2 * y_ind - 1, np.array([self.C]), solver=self.solver
          )[0]
          self.coef_ = coefs.T  # must be [1, n_features]
          self.intercept_ = 0
      else:
          self.intercept_ = 0.0
          multiclass = OneVsRestClassifier(self).fit(X, y)
          self.coef_ = np.array(
              [clf.coef_[0] for clf in multiclass.estimators_]
          )
          # self.n_iter_ = max(clf.n_iter_ for clf in multiclass.estimators_)
          # TODO implement n_iter for logreg?
  
      return self
  
imports: import numbers
  import numpy
  from sklearn.base import RegressorMixin, MultiOutputMixin
  from sklearn.utils.validation import check_X_y
  from sklearn.utils.multiclass import check_classification_targets
  from sklearn.linear_model import ElasticNet, Lasso, LogisticRegression, MultiTaskLasso
  from sklearn.linear_model._coordinate_descent import LinearModelCV
  from sklearn.linear_model._base import _preprocess_data
  from sklearn.preprocessing import LabelEncoder
  from sklearn.multiclass import OneVsRestClassifier
  from .homotopy import celer_path, mtl_path
label_desc: Use image node_id 2 for calling the LogisticRegression obj's underlying member method code with example usage: obj.fit(X, y) and returns: self