Graphical estimators

Sparse inverse-covariance (precision matrix) estimators, single- and multi-population.

For the conceptual model — what a precision matrix is, why zeros correspond to conditional independence, when to choose nonconvex penalties over L1 — see Graphical models.

Single-population

All three accept either raw X (n, p) or a precomputed (p, p) symmetric covariance (sniffed automatically). Fitted attributes: precision_, covariance_, info_, n_features_in_.

class skein_glm.estimators.GraphicalLasso(alpha=0.1, *, edge_weights=None, assume_centered=False, diag_offset=None, max_iter=100, tol=0.0001, inner_max_iter=200, inner_tol=1e-06)[source]

Bases: _GraphicalEstimatorBase

L1-penalised sparse inverse covariance (graphical lasso).

Estimates a sparse precision matrix Θ = Σ⁻¹ by solving the L1-penalised Gaussian log-likelihood with off-diagonal-only weights, via the Friedman/Hastie/Tibshirani 2008 block-coordinate-descent algorithm. Zeros in Θ correspond to conditional independence between variables — the standard interpretation of a Gaussian graphical model.

Parameters:
  • alpha (float, default 0.1) – L1 regularisation strength. Larger → sparser graph.

  • edge_weights ((p, p) array or None) – Per-edge weights (zero diagonal ignored). Adaptive glasso falls out for free: set edge_weights[i, j] = 1 / |Θ̂_init[i, j]|.

  • assume_centered (bool, default False) – Skip mean-centering when computing the empirical covariance.

  • diag_offset (float or None) – Added to the diagonal of S at initialisation; numerical safety to keep W positive definite. Defaults to alpha if None, matching sklearn’s convention.

  • max_iter (int, default 100)

  • tol (float, default 1e-4)

  • inner_max_iter (int, default 200)

  • inner_tol (float, default 1e-6)

precision_

Estimated precision matrix Θ̂.

Type:

ndarray of shape (p, p)

covariance_

Working covariance estimate Ŵ at convergence.

Type:

ndarray of shape (p, p)

info_
Type:

dict

n_features_in_
Type:

int

class skein_glm.estimators.GraphicalMCP(alpha=0.1, gamma=3.0, *, edge_weights=None, assume_centered=False, diag_offset=None, max_iter=100, tol=0.0001, inner_max_iter=200, inner_tol=1e-06)[source]

Bases: GraphicalLasso

MCP-penalised sparse inverse covariance — reduces the shrinkage bias of the standard L1 glasso by transitioning to identity above gamma · alpha. Same fit API and fitted attributes as GraphicalLasso.

Parameters:
  • gamma (float, default 3.0) – MCP nonconvexity parameter (> 1). gamma → ∞ recovers GraphicalLasso.

  • alpha (float)

  • edge_weights (NDArray[np.float64] | None)

  • assume_centered (bool)

  • diag_offset (float | None)

  • max_iter (int)

  • tol (float)

  • inner_max_iter (int)

  • inner_tol (float)

class skein_glm.estimators.GraphicalSCAD(alpha=0.1, a=3.7, *, edge_weights=None, assume_centered=False, diag_offset=None, max_iter=100, tol=0.0001, inner_max_iter=200, inner_tol=1e-06)[source]

Bases: GraphicalLasso

SCAD-penalised sparse inverse covariance. Same fit API and fitted attributes as GraphicalLasso.

Parameters:
  • a (float, default 3.7) – SCAD shape parameter (> 2). a → ∞ recovers GraphicalLasso.

  • alpha (float)

  • edge_weights (NDArray[np.float64] | None)

  • assume_centered (bool)

  • diag_offset (float | None)

  • max_iter (int)

  • tol (float)

  • inner_max_iter (int)

  • inner_tol (float)

Joint estimation across populations

JointGraphicalLasso and JointGraphicalMCP fit K precision matrices simultaneously with a group penalty on each edge across populations. Accept a list of arrays (one per population), each raw or precomputed cov. Fitted attributes: precisions_, info_, n_features_in_, n_populations_.

class skein_glm.estimators.JointGraphicalLasso(lambda_2=0.1, *, edge_weights=None, assume_centered=False, rho=1.0, diag_offset=0.0, max_iter=200, primal_tol=1e-05, dual_tol=1e-05)[source]

Bases: _JointGraphicalBase

Joint graphical lasso across K related populations (Danaher–Wang–Witten 2014, group form).

Estimates K precision matrices Θ̂^(1), …, Θ̂^(K) simultaneously with a group penalty coupling the same edge across populations. The coupling parameter lambda_2 controls how much the edges align across populations: lambda_2 = 0 decouples to K independent fits; large lambda_2 collapses to identical estimates.

Parameters:
  • lambda_2 (float, default 0.1) – Across-population coupling strength.

  • edge_weights ((p, p) array or None) – Per-edge coupling weights.

  • assume_centered (bool, default False)

  • rho (float, default 1.0) – ADMM penalty parameter.

  • diag_offset (float, default 0.0)

  • max_iter (int, default 200)

  • primal_tol (float, default 1e-5)

  • dual_tol (float, default 1e-5)

precisions_
Type:

list of K ndarrays of shape (p, p)

info_
Type:

dict

n_features_in_
Type:

int

n_populations_
Type:

int

Notes

First ADMM-based solver in skein. Solves the group form of joint glasso; the fused form (TV across populations) is not yet implemented.

set_fit_request(*, Xs='$UNCHANGED$')

Configure whether metadata should be requested to be passed to the fit method.

Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with enable_metadata_routing=True (see sklearn.set_config()). Please check the User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to fit if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to fit.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

Added in version 1.3.

Parameters:
Returns:

self – The updated object.

Return type:

object

class skein_glm.estimators.JointGraphicalMCP(lambda_2=0.1, gamma=3.0, *, edge_weights=None, assume_centered=False, rho=1.0, diag_offset=0.0, max_iter=200, primal_tol=1e-05, dual_tol=1e-05)[source]

Bases: JointGraphicalLasso

Joint graphical lasso with group MCP coupling. Same fit API and fitted attributes as JointGraphicalLasso.

Parameters:
  • gamma (float, default 3.0) – Group-MCP nonconvexity parameter.

  • lambda_2 (float)

  • edge_weights (NDArray[np.float64] | None)

  • assume_centered (bool)

  • rho (float)

  • diag_offset (float)

  • max_iter (int)

  • primal_tol (float)

  • dual_tol (float)

set_fit_request(*, Xs='$UNCHANGED$')

Configure whether metadata should be requested to be passed to the fit method.

Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with enable_metadata_routing=True (see sklearn.set_config()). Please check the User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to fit if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to fit.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

Added in version 1.3.

Parameters:
Returns:

self – The updated object.

Return type:

object

Choosing α (and λ for joint)

For single-population, see ebic_path — the field-standard Extended-BIC tuner from Foygel & Drton (2010). For joint, joint_ebic_path walks the λ_2 coupling grid.