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:
_GraphicalEstimatorBaseL1-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, default0.1) – L1 regularisation strength. Larger → sparser graph.edge_weights (
(p,p) arrayorNone) – Per-edge weights (zero diagonal ignored). Adaptive glasso falls out for free: set edge_weights[i, j] = 1 / |Θ̂_init[i, j]|.assume_centered (
bool, defaultFalse) – Skip mean-centering when computing the empirical covariance.diag_offset (
floatorNone) – 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, default100)tol (
float, default1e-4)inner_max_iter (
int, default200)inner_tol (
float, default1e-6)
- precision_¶
Estimated precision matrix Θ̂.
- Type:
ndarrayofshape (p,p)
- covariance_¶
Working covariance estimate Ŵ at convergence.
- Type:
ndarrayofshape (p,p)
- 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:
GraphicalLassoMCP-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.
- 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:
GraphicalLassoSCAD-penalised sparse inverse covariance. Same fit API and fitted attributes as
GraphicalLasso.
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:
_JointGraphicalBaseJoint 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, default0.1) – Across-population coupling strength.edge_weights (
(p,p) arrayorNone) – Per-edge coupling weights.rho (
float, default1.0) – ADMM penalty parameter.diag_offset (
float, default0.0)max_iter (
int, default200)primal_tol (
float, default1e-5)dual_tol (
float, default1e-5)
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
fitmethod.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(seesklearn.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 tofitif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it tofit.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.
- 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:
JointGraphicalLassoJoint graphical lasso with group MCP coupling. Same fit API and fitted attributes as
JointGraphicalLasso.- Parameters:
- set_fit_request(*, Xs='$UNCHANGED$')¶
Configure whether metadata should be requested to be passed to the
fitmethod.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(seesklearn.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 tofitif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it tofit.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.
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.