yobx.sklearn.decomposition.factor_analysis#

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

Converts a sklearn.decomposition.FactorAnalysis into ONNX.

The transformation computes the expected mean of the latent variables (see Barber, 21.2.33 or Bishop, 12.66). All constant matrices are pre-computed at conversion time so the resulting ONNX graph is as simple as the PCA converter:

Wpsi   = components_ / noise_variance_          # (n_components, n_features)
cov_z  = inv(I + Wpsi @ components_.T)          # (n_components, n_components)
W_eff  = Wpsi.T @ cov_z                         # (n_features,  n_components)

X  ──Sub(mean_)──►  centered  ──MatMul(W_eff)──►  output
Parameters:
  • g – the graph builder to add nodes to

  • sts – shapes defined by scikit-learn

  • estimator – a fitted FactorAnalysis

  • outputs – desired output names (latent variables)

  • X – input tensor name

  • name – prefix name for the added nodes

Returns:

output tensor name