yobx.sklearn.decomposition.sparse_pca#
- yobx.sklearn.decomposition.sparse_pca.sklearn_sparse_pca(g: GraphBuilderExtendedProtocol, sts: Dict, outputs: List[str], estimator: SparsePCA | MiniBatchSparsePCA, X: str, name: str = 'sparse_pca') str[source]#
Converts a
sklearn.decomposition.SparsePCAorsklearn.decomposition.MiniBatchSparsePCAinto ONNX.The transformation replicates
sklearn.decomposition.SparsePCA.transform():Centre the data by subtracting the per-feature mean stored in
mean_.Apply the pre-computed projection matrix W via a single matrix multiplication, where W is derived from the fitted dictionary
components_and the regularisation parameterridge_alpha:
with
=
components_and=
ridge_alpha.The full graph is:
X ──Sub(mean_)──► centered ──MatMul(W)──► output
- Parameters:
g – the graph builder to add nodes to
sts – shapes defined by scikit-learn
estimator – a fitted
SparsePCAorMiniBatchSparsePCAoutputs – desired output names (sparse codes)
X – input tensor name
name – prefix name for the added nodes
- Returns:
output tensor name