yobx.sklearn.discriminant_analysis.lda#

yobx.sklearn.discriminant_analysis.lda.sklearn_linear_discriminant_analysis(g: GraphBuilderExtendedProtocol, sts: Dict, outputs: List[str], estimator: LinearDiscriminantAnalysis, X: str, name: str = 'lda') Tuple[str, str][source]#

Converts a sklearn.discriminant_analysis.LinearDiscriminantAnalysis into ONNX.

The decision function is computed as a linear transformation of the input, and probabilities are derived from it:

Binary classification (coef_.shape[0] == 1):

X  ──Gemm(coef, intercept)──►  decision (Nx1)
                                    │
                           ┌────────┴────────┐
                        Sigmoid           Sub(1, ·)
                           │                  │
                        proba_pos          proba_neg
                           └────────┬────────┘
                                 Concat  ──►  probabilities
                                    │
                                 ArgMax ──Cast──Gather(classes) ──►  label

Multiclass (coef_.shape[0] > 1):

X  ──Gemm(coef, intercept)──►  decision (NxC)
                                    │
                                Softmax  ──►  probabilities
                                    │
                                ArgMax ──Cast──Gather(classes)  ──►  label
Parameters:
  • g – the graph builder to add nodes to

  • sts – shapes defined by scikit-learn

  • estimator – a fitted LinearDiscriminantAnalysis

  • outputs – desired names (label, probabilities)

  • X – input tensor name

  • name – prefix names for the added nodes

Returns:

tuple (label_result_name, proba_result_name)