yobx.sklearn.linear_model.logistic_regression#

yobx.sklearn.linear_model.logistic_regression.sklearn_logistic_regression(g: GraphBuilderExtendedProtocol, sts: Dict, outputs: List[str], estimator: LogisticRegression | LogisticRegressionCV, X: str, name: str = 'logistic_regression') Tuple[str, str][source]#

Converts a class sklearn.linear_model.LogisticRegression into ONNX.

The graph structure depends on the number of classes.

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

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

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

X  ──Gemm(coef, intercept)──►  decision
                                   │
                               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 LogisticRegression

  • outputs – desired names (label, probabilities)

  • X – inputs

  • name – prefix names for the added nodes

Returns:

tuple (label_result_name, proba_result_name)