yobx.sklearn.decomposition.pca#

yobx.sklearn.decomposition.pca.sklearn_pca(g: GraphBuilderExtendedProtocol, sts: Dict, outputs: List[str], estimator: PCA, X: str, name: str = 'pca') str[source]#

Converts a sklearn.decomposition.PCA into ONNX.

The transformation centres the data when the model was fitted with centering (i.e. mean_ is not None) and then projects it onto the principal components:

X  ──Sub(mean_)──►  centered  ──MatMul(components_.T)──►  output
     (if mean_ is not None)

When mean_ is None the Sub node is skipped.

Parameters:
  • g – the graph builder to add nodes to

  • sts – shapes defined by scikit-learn

  • estimator – a fitted PCA

  • outputs – desired output names (projected inputs)

  • X – input tensor name

  • name – prefix name for the added nodes

Returns:

output tensor name