yobx.sklearn.svm.one_class_svm#
- yobx.sklearn.svm.one_class_svm.sklearn_one_class_svm(g: GraphBuilderExtendedProtocol, sts: Dict, outputs: List[str], estimator: OneClassSVM, X: str, name: str = 'one_class_svm') str | Tuple[str, str][source]#
Converts a
sklearn.svm.OneClassSVMinto ONNX using theSVMRegressoroperator from theai.onnx.mldomain.Supported kernels:
'linear','poly','rbf','sigmoid'. Callable kernels are not supported.The converter produces two outputs:
label: the outlier predictions (1for inlier,-1for outlier), equivalent topredict().scores: the decision function values, equivalent todecision_function().
Note
The
SVMRegressoroperator only supportsfloat32input. When the input tensor isfloat64, it is cast tofloat32before the SVM node and the resulting scores are cast back tofloat64afterwards. This may introduce small numerical differences compared to running inference withfloat64arithmetic.Graph structure:
X (float64) ──Cast(float32)──► X_f32 │ X (float32) ──────────────────────────┐ ▼ SVMRegressor(one_class=0) ──► raw_scores (N, 1) [float32] │ Reshape ──► scores_f32 (N,) [float32] │ [Cast to float64 if input was float64] │ scores (N,) [input dtype] │ GreaterOrEqual(0) ──► mask (N,) │ Where(1, -1) ──► label (N,)- Parameters:
g – the graph builder to add nodes to
sts – shapes defined by scikit-learn
outputs – desired output names;
outputs[0]receives the predicted labels andoutputs[1](if present) receives the decision function valuesestimator – a fitted
OneClassSVMX – input tensor name
name – prefix for added node names
- Returns:
label tensor name, or tuple
(label, scores)