yobx.sklearn.svm.svm#

yobx.sklearn.svm.svm.sklearn_svc(g: GraphBuilderExtendedProtocol, sts: Dict, outputs: List[str], estimator: SVC | NuSVC, X: str, name: str = 'svc') str | Tuple[str, str][source]#

Converts a sklearn.svm.SVC or sklearn.svm.NuSVC into ONNX using the SVMClassifier operator from the ai.onnx.ml domain.

Supported kernels: 'linear', 'poly', 'rbf', 'sigmoid'. Callable kernels are not supported.

When the estimator was trained with probability=True (i.e., it exposes predict_proba()), the converter includes the Platt scaling calibration parameters prob_a / prob_b in the SVMClassifier node, which causes the ONNX runtime to output calibrated probabilities automatically. The output is then the tuple (label, probabilities). Without probability=True, only the predicted label is returned.

Coefficient layout for the SVMClassifier node:

  • Binary (2 classes): ONNX coefficients = -dual_coef_.flatten(), rho = -intercept_.

  • Multiclass (≥ 3 classes, OvO): ONNX coefficients = dual_coef_.flatten(), rho = intercept_.

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

  • sts – shapes defined by scikit-learn

  • outputs – desired output names (label only, or label + probabilities)

  • estimator – a fitted SVC or NuSVC

  • X – input tensor name

  • name – prefix for added node names

Returns:

label tensor name, or tuple (label, probabilities)

yobx.sklearn.svm.svm.sklearn_svr(g: GraphBuilderExtendedProtocol, sts: Dict, outputs: List[str], estimator: SVR | NuSVR, X: str, name: str = 'svr') str[source]#

Converts a sklearn.svm.SVR or sklearn.svm.NuSVR into ONNX using the SVMRegressor operator from the ai.onnx.ml domain.

Supported kernels: 'linear', 'poly', 'rbf', 'sigmoid'. Callable kernels are not supported.

Graph structure:

X  ──SVMRegressor──►  predictions (N,1)
Parameters:
  • g – the graph builder to add nodes to

  • sts – shapes defined by scikit-learn

  • outputs – desired output names

  • estimator – a fitted SVR or NuSVR

  • X – input tensor name

  • name – prefix for added node names

Returns:

output tensor name