class_docstr: Sparse inverse covariance w/ cross-validated choice of the l1 penalty.
  
  See glossary entry for :term:`cross-validation estimator`.
  
  Read more in the :ref:`User Guide <sparse_inverse_covariance>`.
  
  .. versionchanged:: v0.20
      GraphLassoCV has been renamed to GraphicalLassoCV
  
  Parameters
  ----------
  alphas : int or array-like of shape (n_alphas,), dtype=float, default=4
      If an integer is given, it fixes the number of points on the
      grids of alpha to be used. If a list is given, it gives the
      grid to be used. See the notes in the class docstring for
      more details. Range is [1, inf) for an integer.
      Range is (0, inf] for an array-like of floats.
  
  n_refinements : int, default=4
      The number of times the grid is refined. Not used if explicit
      values of alphas are passed. Range is [1, inf).
  
  cv : int, cross-validation generator or iterable, default=None
      Determines the cross-validation splitting strategy.
      Possible inputs for cv are:
  
      - None, to use the default 5-fold cross-validation,
      - integer, to specify the number of folds.
      - :term:`CV splitter`,
      - An iterable yielding (train, test) splits as arrays of indices.
  
      For integer/None inputs :class:`~sklearn.model_selection.KFold` is used.
  
      Refer :ref:`User Guide <cross_validation>` for the various
      cross-validation strategies that can be used here.
  
      .. versionchanged:: 0.20
          ``cv`` default value if None changed from 3-fold to 5-fold.
  
  tol : float, default=1e-4
      The tolerance to declare convergence: if the dual gap goes below
      this value, iterations are stopped. Range is (0, inf].
  
  enet_tol : float, default=1e-4
      The tolerance for the elastic net solver used to calculate the descent
      direction. This parameter controls the accuracy of the search direction
      for a given column update, not of the overall parameter estimate. Only
      used for mode='cd'. Range is (0, inf].
  
  max_iter : int, default=100
      Maximum number of iterations.
  
  mode : {'cd', 'lars'}, default='cd'
      The Lasso solver to use: coordinate descent or LARS. Use LARS for
      very sparse underlying graphs, where number of features is greater
      than number of samples. Elsewhere prefer cd which is more numerically
      stable.
  
  n_jobs : int, default=None
      Number of jobs to run in parallel.
      ``None`` means 1 unless in a :obj:`joblib.parallel_backend` context.
      ``-1`` means using all processors. See :term:`Glossary <n_jobs>`
      for more details.
  
      .. versionchanged:: v0.20
         `n_jobs` default changed from 1 to None
  
  verbose : bool, default=False
      If verbose is True, the objective function and duality gap are
      printed at each iteration.
  
  eps : float, default=eps
      The machine-precision regularization in the computation of the
      Cholesky diagonal factors. Increase this for very ill-conditioned
      systems. Default is `np.finfo(np.float64).eps`.
  
      .. versionadded:: 1.3
  
  assume_centered : bool, default=False
      If True, data are not centered before computation.
      Useful when working with data whose mean is almost, but not exactly
      zero.
      If False, data are centered before computation.
  
  Attributes
  ----------
  location_ : ndarray of shape (n_features,)
      Estimated location, i.e. the estimated mean.
  
  covariance_ : ndarray of shape (n_features, n_features)
      Estimated covariance matrix.
  
  precision_ : ndarray of shape (n_features, n_features)
      Estimated precision matrix (inverse covariance).
  
  costs_ : list of (objective, dual_gap) pairs
      The list of values of the objective function and the dual gap at
      each iteration. Returned only if return_costs is True.
  
      .. versionadded:: 1.3
  
  alpha_ : float
      Penalization parameter selected.
  
  cv_results_ : dict of ndarrays
      A dict with keys:
  
      alphas : ndarray of shape (n_alphas,)
          All penalization parameters explored.
  
      split(k)_test_score : ndarray of shape (n_alphas,)
          Log-likelihood score on left-out data across (k)th fold.
  
          .. versionadded:: 1.0
  
      mean_test_score : ndarray of shape (n_alphas,)
          Mean of scores over the folds.
  
          .. versionadded:: 1.0
  
      std_test_score : ndarray of shape (n_alphas,)
          Standard deviation of scores over the folds.
  
          .. versionadded:: 1.0
  
  n_iter_ : int
      Number of iterations run for the optimal alpha.
  
  n_features_in_ : int
      Number of features seen during :term:`fit`.
  
      .. versionadded:: 0.24
  
  feature_names_in_ : ndarray of shape (`n_features_in_`,)
      Names of features seen during :term:`fit`. Defined only when `X`
      has feature names that are all strings.
  
      .. versionadded:: 1.0
  
  See Also
  --------
  graphical_lasso : L1-penalized covariance estimator.
  GraphicalLasso : Sparse inverse covariance estimation
      with an l1-penalized estimator.
  
  Notes
  -----
  The search for the optimal penalization parameter (`alpha`) is done on an
  iteratively refined grid: first the cross-validated scores on a grid are
  computed, then a new refined grid is centered around the maximum, and so
  on.
  
  One of the challenges which is faced here is that the solvers can
  fail to converge to a well-conditioned estimate. The corresponding
  values of `alpha` then come out as missing values, but the optimum may
  be close to these missing values.
  
  In `fit`, once the best parameter `alpha` is found through
  cross-validation, the model is fit again using the entire training set.
  
  Examples
  --------
  >>> import numpy as np
  >>> from sklearn.covariance import GraphicalLassoCV
  >>> true_cov = np.array([[0.8, 0.0, 0.2, 0.0],
  ...                      [0.0, 0.4, 0.0, 0.0],
  ...                      [0.2, 0.0, 0.3, 0.1],
  ...                      [0.0, 0.0, 0.1, 0.7]])
  >>> np.random.seed(0)
  >>> X = np.random.multivariate_normal(mean=[0, 0, 0, 0],
  ...                                   cov=true_cov,
  ...                                   size=200)
  >>> cov = GraphicalLassoCV().fit(X)
  >>> np.around(cov.covariance_, decimals=3)
  array([[0.816, 0.051, 0.22 , 0.017],
         [0.051, 0.364, 0.018, 0.036],
         [0.22 , 0.018, 0.322, 0.094],
         [0.017, 0.036, 0.094, 0.69 ]])
  >>> np.around(cov.location_, decimals=3)
  array([0.073, 0.04 , 0.038, 0.143])
class_docstr_tok: ["Sparse","inverse","covariance","w\/","cross-validated","choice","of","the","l1","penalty",".","See","glossary","entry","for",":","term",":","`","cross-validation","estimator","`",".","Read","more","in","the",":","ref",":","`","User","Guide","<","sparse_inverse_covariance",">","`",".","..","versionchanged",":",":","v0.20","GraphLassoCV","has","been","renamed","to","GraphicalLassoCV","Parameters","--","--","--","--","--","alphas",":","int","or","array-like","of","shape","(","n_alphas",",",")",",","dtype=float",",","default=4","If","an","integer","is","given",",","it","fixes","the","number","of","points","on","the","grids","of","alpha","to","be","used",".","If","a","list","is","given",",","it","gives","the","grid","to","be","used",".","See","the","notes","in","the","class","docstring","for","more","details",".","Range","is","[","1",",","inf",")","for","an","integer",".","Range","is","(","0",",","inf","]","for","an","array-like","of","floats",".","n_refinements",":","int",",","default=4","The","number","of","times","the","grid","is","refined",".","Not","used","if","explicit","values","of","alphas","are","passed",".","Range","is","[","1",",","inf",")",".","cv",":","int",",","cross-validation","generator","or","iterable",",","default=None","Determines","the","cross-validation","splitting","strategy",".","Possible","inputs","for","cv","are",":","-","None",",","to","use","the","default","5-fold","cross-validation",",","-","integer",",","to","specify","the","number","of","folds",".","-",":","term",":","`","CV","splitter","`",",","-","An","iterable","yielding","(","train",",","test",")","splits","as","arrays","of","indices",".","For","integer\/None","inputs",":","class",":","`","~sklearn.model_selection.KFold","`","is","used",".","Refer",":","ref",":","`","User","Guide","<","cross_validation",">","`","for","the","various","cross-validation","strategies","that","can","be","used","here",".","..","versionchanged",":",":","0.20","``","cv","``","default","value","if","None","changed","from","3-fold","to","5-fold",".","tol",":","float",",","default=1e-4","The","tolerance","to","declare","convergence",":","if","the","dual","gap","goes","below","this","value",",","iterations","are","stopped",".","Range","is","(","0",",","inf","]",".","enet_tol",":","float",",","default=1e-4","The","tolerance","for","the","elastic","net","solver","used","to","calculate","the","descent","direction",".","This","parameter","controls","the","accuracy","of","the","search","direction","for","a","given","column","update",",","not","of","the","overall","parameter","estimate",".","Only","used","for","mode='cd","'",".","Range","is","(","0",",","inf","]",".","max_iter",":","int",",","default=100","Maximum","number","of","iterations",".","mode",":","{","'cd","'",",","'lars","'","}",",","default='cd'","The","Lasso","solver","to","use",":","coordinate","descent","or","LARS",".","Use","LARS","for","very","sparse","underlying","graphs",",","where","number","of","features","is","greater","than","number","of","samples",".","Elsewhere","prefer","cd","which","is","more","numerically","stable",".","n_jobs",":","int",",","default=None","Number","of","jobs","to","run","in","parallel",".","``","None","``","means","1","unless","in","a",":","obj",":","`","joblib.parallel_backend","`","context",".","``","-1","``","means","using","all","processors",".","See",":","term",":","`","Glossary","<","n_jobs",">","`","for","more","details",".","..","versionchanged",":",":","v0.20","`","n_jobs","`","default","changed","from","1","to","None","verbose",":","bool",",","default=False","If","verbose","is","True",",","the","objective","function","and","duality","gap","are","printed","at","each","iteration",".","eps",":","float",",","default=eps","The","machine-precision","regularization","in","the","computation","of","the","Cholesky","diagonal","factors",".","Increase","this","for","very","ill-conditioned","systems",".","Default","is","`","np.finfo","(","np.float64",")",".eps","`",".","..","versionadded",":",":","1.3","assume_centered",":","bool",",","default=False","If","True",",","data","are","not","centered","before","computation",".","Useful","when","working","with","data","whose","mean","is","almost",",","but","not","exactly","zero",".","If","False",",","data","are","centered","before","computation",".","Attributes","--","--","--","--","--","location_",":","ndarray","of","shape","(","n_features",",",")","Estimated","location",",","i.e",".","the","estimated","mean",".","covariance_",":","ndarray","of","shape","(","n_features",",","n_features",")","Estimated","covariance","matrix",".","precision_",":","ndarray","of","shape","(","n_features",",","n_features",")","Estimated","precision","matrix","(","inverse","covariance",")",".","costs_",":","list","of","(","objective",",","dual_gap",")","pairs","The","list","of","values","of","the","objective","function","and","the","dual","gap","at","each","iteration",".","Returned","only","if","return_costs","is","True",".","..","versionadded",":",":","1.3","alpha_",":","float","Penalization","parameter","selected",".","cv_results_",":","dict","of","ndarrays","A","dict","with","keys",":","alphas",":","ndarray","of","shape","(","n_alphas",",",")","All","penalization","parameters","explored",".","split","(","k",")","_test_score",":","ndarray","of","shape","(","n_alphas",",",")","Log-likelihood","score","on","left-out","data","across","(","k",")","th","fold",".","..","versionadded",":",":","1.0","mean_test_score",":","ndarray","of","shape","(","n_alphas",",",")","Mean","of","scores","over","the","folds",".","..","versionadded",":",":","1.0","std_test_score",":","ndarray","of","shape","(","n_alphas",",",")","Standard","deviation","of","scores","over","the","folds",".","..","versionadded",":",":","1.0","n_iter_",":","int","Number","of","iterations","run","for","the","optimal","alpha",".","n_features_in_",":","int","Number","of","features","seen","during",":","term",":","`","fit","`",".","..","versionadded",":",":","0.24","feature_names_in_",":","ndarray","of","shape","(","`","n_features_in_","`",",",")","Names","of","features","seen","during",":","term",":","`","fit","`",".","Defined","only","when","`","X","`","has","feature","names","that","are","all","strings",".","..","versionadded",":",":","1.0","See","Also","--","--","--","--","graphical_lasso",":","L1-penalized","covariance","estimator",".","GraphicalLasso",":","Sparse","inverse","covariance","estimation","with","an","l1-penalized","estimator",".","Notes","--","--","-","The","search","for","the","optimal","penalization","parameter","(","`","alpha","`",")","is","done","on","an","iteratively","refined","grid",":","first","the","cross-validated","scores","on","a","grid","are","computed",",","then","a","new","refined","grid","is","centered","around","the","maximum",",","and","so","on",".","One","of","the","challenges","which","is","faced","here","is","that","the","solvers","can","fail","to","converge","to","a","well-conditioned","estimate",".","The","corresponding","values","of","`","alpha","`","then","come","out","as","missing","values",",","but","the","optimum","may","be","close","to","these","missing","values",".","In","`","fit","`",",","once","the","best","parameter","`","alpha","`","is","found","through","cross-validation",",","the","model","is","fit","again","using","the","entire","training","set",".","Examples","--","--","--","--",">",">",">","import","numpy","as","np",">",">",">","from","sklearn.covariance","import","GraphicalLassoCV",">",">",">","true_cov","=","np.array","(","[","[","0.8",",","0.0",",","0.2",",","0.0","]",",","...","[","0.0",",","0.4",",","0.0",",","0.0","]",",","...","[","0.2",",","0.0",",","0.3",",","0.1","]",",","...","[","0.0",",","0.0",",","0.1",",","0.7","]","]",")",">",">",">","np.random.seed","(","0",")",">",">",">","X","=","np.random.multivariate_normal","(","mean=","[","0",",","0",",","0",",","0","]",",","...","cov=true_cov",",","...","size=200",")",">",">",">","cov","=","GraphicalLassoCV","(",")",".fit","(","X",")",">",">",">","np.around","(","cov.covariance_",",","decimals=3",")","array","(","[","[","0.816",",","0.051",",","0.22",",","0.017","]",",","[","0.051",",","0.364",",","0.018",",","0.036","]",",","[","0.22",",","0.018",",","0.322",",","0.094","]",",","[","0.017",",","0.036",",","0.094",",","0.69","]","]",")",">",">",">","np.around","(","cov.location_",",","decimals=3",")","array","(","[","0.073",",","0.04",",","0.038",",","0.143","]",")"]
docstr: Fit the GraphicalLasso covariance model to X.
  
  Parameters
  ----------
  X : array-like of shape (n_samples, n_features)
      Data from which to compute the covariance estimate.
  
  y : Ignored
      Not used, present for API consistency by convention.
  
  Returns
  -------
  self : object
      Returns the instance itself.
docstr_tok: ["Fit","the","GraphicalLasso","covariance","model","to","X.","Parameters","--","--","--","--","--","X",":","array-like","of","shape","(","n_samples",",","n_features",")","Data","from","which","to","compute","the","covariance","estimate",".","y",":","Ignored","Not","used",",","present","for","API","consistency","by","convention",".","Returns","--","--","--","-","self",":","object","Returns","the","instance","itself","."]
code: def fit(self, X, y=None):
      """Fit the GraphicalLasso covariance model to X.
  
      Parameters
      ----------
      X : array-like of shape (n_samples, n_features)
          Data from which to compute the covariance estimate.
  
      y : Ignored
          Not used, present for API consistency by convention.
  
      Returns
      -------
      self : object
          Returns the instance itself.
      """
      # Covariance does not make sense for a single feature
      X = self._validate_data(X, ensure_min_features=2)
      if self.assume_centered:
          self.location_ = np.zeros(X.shape[1])
      else:
          self.location_ = X.mean(0)
      emp_cov = empirical_covariance(
          X, assume_centered=self.assume_centered
      )
  
      cv = check_cv(self.cv, y, classifier=False)
  
      # List of (alpha, scores, covs)
      path = list()
      n_alphas = self.alphas
      inner_verbose = max(0, self.verbose - 1)
  
      if _is_arraylike_not_scalar(n_alphas):
          for alpha in self.alphas:
              check_scalar(
                  alpha,
                  "alpha",
                  Real,
                  min_val=0,
                  max_val=np.inf,
                  include_boundaries="right",
              )
          alphas = self.alphas
          n_refinements = 1
      else:
          n_refinements = self.n_refinements
          alpha_1 = alpha_max(emp_cov)
          alpha_0 = 1e-2 * alpha_1
          alphas = np.logspace(
              np.log10(alpha_0), np.log10(alpha_1), n_alphas
          )[::-1]
  
      t0 = time.time()
      for i in range(n_refinements):
          with warnings.catch_warnings():
              # No need to see the convergence warnings on this grid:
              # they will always be points that will not converge
              # during the cross-validation
              warnings.simplefilter("ignore", ConvergenceWarning)
              # Compute the cross-validated loss on the current grid
  
              # NOTE: Warm-restarting graphical_lasso_path has been tried,
              # and this did not allow to gain anything
              # (same execution time with or without).
              this_path = Parallel(
                  n_jobs=self.n_jobs, verbose=self.verbose
              )(
                  delayed(graphical_lasso_path)(
                      X[train],
                      alphas=alphas,
                      X_test=X[test],
                      mode=self.mode,
                      tol=self.tol,
                      enet_tol=self.enet_tol,
                      max_iter=int(0.1 * self.max_iter),
                      verbose=inner_verbose,
                      eps=self.eps,
                  )
                  for train, test in cv.split(X, y)
              )
  
          # Little danse to transform the list in what we need
          covs, _, scores = zip(*this_path)
          covs = zip(*covs)
          scores = zip(*scores)
          path.extend(zip(alphas, scores, covs))
          path = sorted(path, key=operator.itemgetter(0), reverse=True)
  
          # Find the maximum (avoid using built in 'max' function to
          # have a fully-reproducible selection of the smallest alpha
          # in case of equality)
          best_score = -np.inf
          last_finite_idx = 0
          for index, (alpha, scores, _) in enumerate(path):
              this_score = np.mean(scores)
              if this_score >= 0.1 / np.finfo(np.float64).eps:
                  this_score = np.nan
              if np.isfinite(this_score):
                  last_finite_idx = index
              if this_score >= best_score:
                  best_score = this_score
                  best_index = index
  
          # Refine the grid
          if best_index == 0:
              # We do not need to go back: we have chosen
              # the highest value of alpha for which there are
              # non-zero coefficients
              alpha_1 = path[0][0]
              alpha_0 = path[1][0]
          elif (
              best_index == last_finite_idx
              and not best_index == len(path) - 1
          ):
              # We have non-converged models on the upper bound of the
              # grid, we need to refine the grid there
              alpha_1 = path[best_index][0]
              alpha_0 = path[best_index + 1][0]
          elif best_index == len(path) - 1:
              alpha_1 = path[best_index][0]
              alpha_0 = 0.01 * path[best_index][0]
          else:
              alpha_1 = path[best_index - 1][0]
              alpha_0 = path[best_index + 1][0]
  
          if not _is_arraylike_not_scalar(n_alphas):
              alphas = np.logspace(
                  np.log10(alpha_1), np.log10(alpha_0), n_alphas + 2
              )
              alphas = alphas[1:-1]
  
          if self.verbose and n_refinements > 1:
              print(
                  "[GraphicalLassoCV] Done refinement % 2i out of %i: % 3is"
                  % (i + 1, n_refinements, time.time() - t0)
              )
  
      path = list(zip(*path))
      grid_scores = list(path[1])
      alphas = list(path[0])
      # Finally, compute the score with alpha = 0
      alphas.append(0)
      grid_scores.append(
          cross_val_score(
              EmpiricalCovariance(),
              X,
              cv=cv,
              n_jobs=self.n_jobs,
              verbose=inner_verbose,
          )
      )
      grid_scores = np.array(grid_scores)
  
      self.cv_results_ = {"alphas": np.array(alphas)}
  
      for i in range(grid_scores.shape[1]):
          self.cv_results_[f"split{i}_test_score"] = grid_scores[:, i]
  
      self.cv_results_["mean_test_score"] = np.mean(grid_scores, axis=1)
      self.cv_results_["std_test_score"] = np.std(grid_scores, axis=1)
  
      best_alpha = alphas[best_index]
      self.alpha_ = best_alpha
  
      # Finally fit the model with the selected alpha
      (
          self.covariance_,
          self.precision_,
          self.costs_,
          self.n_iter_,
      ) = _graphical_lasso(
          emp_cov,
          alpha=best_alpha,
          mode=self.mode,
          tol=self.tol,
          enet_tol=self.enet_tol,
          max_iter=self.max_iter,
          verbose=inner_verbose,
          eps=self.eps,
      )
      return self
  
imports: import operator
  import sys
  import time
  import warnings
  from numbers import Integral, Real
  import numpy
  from scipy import linalg
  from ..base import _fit_context
  from ..exceptions import ConvergenceWarning
  from ..linear_model import _cd_fast
  from ..linear_model import lars_path_gram
  from ..model_selection import check_cv, cross_val_score
  from ..utils._param_validation import Interval, StrOptions, validate_params
  from ..utils.parallel import Parallel, delayed
  from ..utils.validation import _is_arraylike_not_scalar, check_random_state, check_scalar
  from .None import EmpiricalCovariance, empirical_covariance, log_likelihood
label_desc: Use image node_id 2 for calling the GraphicalLassoCV obj's underlying member method code with example usage: obj.fit(X, y) and returns: self