yobx.sklearn.svm.linear_svm#

yobx.sklearn.svm.linear_svm.sklearn_linear_svc(g: GraphBuilderExtendedProtocol, sts: Dict, outputs: List[str], estimator: LinearSVC, X: str, name: str = 'linear_svc') str[source]#

Converts a sklearn.svm.LinearSVC into ONNX.

LinearSVC does not expose predict_proba(), so this converter always returns the predicted class label only.

Binary classification (len(classes_) == 2):

X  ──Gemm(coef, intercept)──►  decision (Nx1)
                                    │
                                Reshape  ──►  decision_1d (N,)
                                    │
                                Greater(0) ──Cast(INT64)──Gather(classes) ──►  label

Multiclass (len(classes_) > 2):

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

  • sts – shapes defined by scikit-learn

  • outputs – desired output names (label only; LinearSVC has no predict_proba)

  • estimator – a fitted LinearSVC

  • X – input tensor name

  • name – prefix for added node names

Returns:

label tensor name

yobx.sklearn.svm.linear_svm.sklearn_linear_svr(g: GraphBuilderExtendedProtocol, sts: Dict, outputs: List[str], estimator: LinearSVR, X: str, name: str = 'linear_svr') str[source]#

Converts a sklearn.svm.LinearSVR into ONNX.

The prediction formula is:

y = X @ coef_.T + intercept_

Graph structure:

X  ──Gemm(coef, intercept, transB=1)──►  predictions
Parameters:
  • g – the graph builder to add nodes to

  • sts – shapes defined by scikit-learn

  • outputs – desired output names

  • estimator – a fitted LinearSVR

  • X – input tensor name

  • name – prefix for added node names

Returns:

output tensor name