class_docstr: Randomized model averaging meta-estimator.
  
  See analogous sklearn.linear_model.BaseRandomizedLinearModel.
  
  Parameters
  -----------
  estimator : An inverse covariance estimator instance
      After being fit, estimator.precision_ must either be a matrix with the
      precision or a list of precision matrices (e.g., path mode).
  
  n_trials : int (default=100)
      Number of random subsets for which to bootstrap the data.
  
  subsample : float in range (0, 1) (default=0.3)
      Fraction of examples to subsample in each bootstrap trial.
  
  normalize : bool (default=True)
      Determines whether the proportion_ matrix should be normalized to have
      values in the range (0, 1) or should be absolute.
  
  lam : float (default=0.5)
      Scalar lambda penalty used in penalization='random' mode.  Will be
      ignored in all other modes.
  
  lam_perturb : float \in (0, 1) (default=0.5)
      Scalar perturbation parameter used in penalization='random'.  Will be
      ignored in all other modes.
  
  init_method : one of 'corrcoef', 'cov', 'spearman', 'kendalltau',
      or a custom function. See InverseCovarianceEstimator
  
  penalization : one of 'subsampling', 'random' (default), 'fully-random'
      Strategy for generating new random penalization in each trial.
  
      subsampling: Only the observations will be subsampled, the original
                   penalty supplied in the estimator instance will be used.
                   Use this technique when the estimator does not support
                   matrix penalization (e.g., sklearn GraphicalLasso).
  
      random: In addition to randomly subsampling the observations, 'random'
              applies a randomly-perturbed 'lam' weight matrix.  The entries
              of the matrix take the value
              {lam * lam_perturb, lam / lam_perturb} with probability 1/2.
              User must supply a scalar 'lam' and 'lam_perturb' parameters.
  
      fully-random: In addition to randomly subsampling the observations,
                    'fully-random' generates a symmetric Gaussian matrix
                    appropriately scaled for the data.
  
      For more information on 'random' penalization, see:
          "Stability Selection"
          N. Meinhausen and P. Buehlmann, May 2009
  
          "Random lasso"
          S. Wang, B. Nan, S. Rosset, and J. Zhu, Apr 2011
  
      For more information on 'fully-random', see:
          "Mixed effects models for resampled network statistics improves
          statistical power to find differences in multi-subject functional
          connectivity"
          M. Narayan and G. Allen, March 2016
  
  support_thresh : float (0, 1)
      Threshold for estimating supports from proportions.  This is provided
      for convience.
  
  penalty_name : string (default='lam')
      Name of the penalty kwarg in the estimator.  This parameter is
      unimportant if penalization='subsampling'.
  
  bootstrap : callable fun (default=_default_bootstrap)
      A function that takes n_samples, num_subsamples as inputs and returns
      a list of sample indices in the range (0, n_samples-1).
      By default, indices are uniformly subsampled.
  
  n_jobs: int (optional)
      number of jobs to run in parallel (default 1).
  
  sc: sparkContext (optional)
      If a sparkContext object is provided, n_jobs will be ignore and the
      work will be parallelized via spark.
  
  seed : np.random.RandomState starting seed. (default=2)
  
  Attributes
  ----------
  proportion_ : matrix of size (n_features, n_features)
      Each entry indicates the sample probability (or count) of whether the
      inverse covariance is non-zero.
  
  support_ : matrix of size (n_features, n_features)
      Support estimate via thresholding proportions by support_thresh.
  
  estimators_ : list of estimator instances (n_trials, )
      The estimator instance from each trial.
      This returns an empty list if use_cache=False.
  
  lams_ : list of penalization matrices (n_trials, )
      The penalization matrix chosen in each trial.
      This returns an empty list if penalization='subsampling'.
  
  subsets_ : list of subset indices (n_trials, )
      The example indices chosen in each trial.
      This returns an empty list if use_cache=False.
  
  lam_ : float
      Average matrix value used among lam_ for all estimators.
docstr: Learn a model averaged proportion matrix for X.
  Parameters
  ----------
  X : ndarray, shape (n_samples, n_features)
      Data from which to compute the proportion matrix.
docstr_tok: ["Learn","a","model","averaged","proportion","matrix","for","X.","Parameters","--","--","--","--","--","X",":","ndarray",",","shape","(","n_samples",",","n_features",")","Data","from","which","to","compute","the","proportion","matrix","."]
code: def fit(self, X, y=None):
      """Learn a model averaged proportion matrix for X.
      Parameters
      ----------
      X : ndarray, shape (n_samples, n_features)
          Data from which to compute the proportion matrix.
      """
      # default to QuicGraphicalLasso
      estimator = self.estimator or QuicGraphicalLasso()
      # To satisfy sklearn
      if y is not None and len(y) == 1:
          raise ValueError("Cannot fit with just 1 sample.")
      self._prng = np.random.RandomState(self.seed)
      if self.penalization != "subsampling" and not hasattr(
          estimator, self.penalty_name
      ):
          raise ValueError(
              (
                  "Must specify valid penalty for "
                  "estimator: {}.".format(self.penalty_name)
              )
          )
  
      self.proportion_ = None
      self.support_ = None
      self.lam_ = None
      self.lam_scale_ = None
      self.estimators_ = []
      self.lams_ = []
      self.subsets_ = []
  
      X = check_array(X, ensure_min_features=2, estimator=self)
      X = as_float_array(X, copy=False, force_all_finite=False)
  
      n_samples_, n_features_ = X.shape
      _, self.lam_scale_ = _init_coefs(X, method=self.init_method)
  
      fit_fun = partial(
          _fit,
          penalization=self.penalization,
          lam=self.lam,
          lam_perturb=self.lam_perturb,
          lam_scale_=self.lam_scale_,
          estimator=estimator,
          penalty_name=self.penalty_name,
          subsample=self.subsample,
          bootstrap=self.bootstrap,
      )
      indexed_param_grid = [(nn,) for nn in range(self.n_trials)]
  
      if self.sc is None:
          results = _cpu_map(
              partial(fit_fun, X=X, prng=self._prng),
              indexed_param_grid,
              n_jobs=self.n_jobs,
          )
      else:
          X_bc = self.sc.broadcast(X)
          results = _spark_map(
              fit_fun, indexed_param_grid, self.sc, self.seed, X_bc
          )
          X_bc.unpersist()
  
      self.estimators_ = [e for r, (l, s, e) in results]
      self.subsets_ = [s for r, (l, s, e) in results]
      self.lams_ = [l for r, (l, s, e) in results]
  
      # reduce
      self.lam_ = 0.0
      self.proportion_ = np.zeros((n_features_, n_features_))
      for new_estimator in self.estimators_:
          # update proportions
          if isinstance(new_estimator.precision_, list):
              for prec in new_estimator.precision_:
                  self.proportion_[np.nonzero(prec)] += 1.0
  
          elif isinstance(new_estimator.precision_, np.ndarray):
              self.proportion_[
                  np.nonzero(new_estimator.precision_)
              ] += 1.0
  
          else:
              raise ValueError("Estimator returned invalid precision_.")
  
          # currently, dont estimate self.lam_ if penalty_name is different
          if self.penalty_name == "lam":
              self.lam_ += np.mean(new_estimator.lam_.flat)
  
      # estimate support locations
      threshold = self.support_thresh * self.n_trials
      self.support_ = np.zeros(self.proportion_.shape)
      self.support_[self.proportion_ > threshold] = 1.0
  
      self.lam_ /= self.n_trials
      if self.normalize:
          self.proportion_ /= self.n_trials
      self.n_features_in_ = X.shape[1]
      return self
  
imports: from __future__ import absolute_import
  import numpy
  from sklearn.base import BaseEstimator, clone
  from sklearn.utils import check_array, as_float_array
  from joblib import Parallel, delayed
  from functools import partial
  from .inverse_covariance import _init_coefs
  from .None import QuicGraphicalLasso
label_desc: Use image node_id 2 for calling the ModelAverage obj's underlying member method code with example usage: obj.fit(X, y) and returns: self