yobx.sklearn.model_selection.tuned_threshold_classifier_cv#
- yobx.sklearn.model_selection.tuned_threshold_classifier_cv.sklearn_tuned_threshold_classifier_cv(g: GraphBuilderExtendedProtocol, sts: Dict, outputs: List[str], estimator: TunedThresholdClassifierCV, X: str, name: str = 'tuned_threshold_classifier_cv') Tuple[str, str][source]#
Converts a
sklearn.model_selection.TunedThresholdClassifierCVinto ONNX.TunedThresholdClassifierCVwraps a binary classifier and adjusts the decision threshold for the positive class to optimise a scoring metric. At inference time it:Obtains the positive-class probability from the inner estimator via
predict_proba.Compares that probability against
best_threshold_.Returns the positive-class label when the probability is ≥
best_threshold_, and the negative-class label otherwise.
The ONNX graph replicates this logic:
X ──[estimator_ converter]──► (inner_label, probas (N, 2)) │ Gather(axis=1, idx=pos_label_idx)──► y_score (N,) │ y_score >= best_threshold_ ──► bool (N,) │ Cast(INT64) ──► 0 or 1 │ Gather(map_thresholded_score_to_label) ──► label_idx (N,) │ Gather(classes_) ──► label (N,)- Parameters:
g – the graph builder to add nodes to
sts – shapes and types defined by scikit-learn
outputs – desired output tensor names for the result
estimator – a fitted
TunedThresholdClassifierCVX – name of the input tensor
name – prefix used for names of nodes added by this converter
- Returns:
tuple
(label, probabilities)- Raises:
NotImplementedError – if the inner estimator does not expose
predict_proba(i.e.response_method='decision_function'was used) — only probability-based thresholding is currently supported