yobx.sklearn.covariance.graphical_lasso#

yobx.sklearn.covariance.graphical_lasso.sklearn_graphical_lasso(g: GraphBuilderExtendedProtocol, sts: Dict, outputs: List[str], estimator, X: str, name: str = 'graphical_lasso') str[source]#

Converts a sklearn.covariance.GraphicalLasso or sklearn.covariance.GraphicalLassoCV into ONNX.

Both estimators expose the same inference interface as EmpiricalCovariance. The converter maps to mahalanobis(), returning the squared Mahalanobis distance from the fitted distribution for each observation:

d^2(x) = (x - \mu)^\top \, \Sigma^{-1} \, (x - \mu)
        = \sum_j \bigl[(x - \mu) \Sigma^{-1}\bigr]_j \cdot (x - \mu)_j

where \mu is location_ and \Sigma^{-1} is precision_.

Full graph structure:

X (N, F)
  │
  └─ Sub(location_) ──► X_centered (N, F)
       │
       ├─ MatMul(precision_) ──► X_prec (N, F)
       │                              │
       └──────────────────── Mul ──► X_prec_centered (N, F)
                                      │
                           ReduceSum(axis=1) ──► mahal_sq (N,)  [output]
Parameters:
  • g – the graph builder to add nodes to

  • sts – shapes defined by scikit-learn

  • outputs – desired output names; outputs[0] receives the squared Mahalanobis distances

  • estimator – a fitted GraphicalLasso or GraphicalLassoCV

  • X – input tensor name

  • name – prefix for added node names

Returns:

output tensor name