yobx.sklearn.neighbors.radiusneighbors#
- yobx.sklearn.neighbors.radiusneighbors.sklearn_radius_neighbors_classifier(g: GraphBuilderExtendedProtocol, sts: Dict, outputs: List[str], estimator: RadiusNeighborsClassifier, X: str, name: str = 'rnn_clf') str | Tuple[str, str][source]#
Converts a
sklearn.neighbors.RadiusNeighborsClassifierinto ONNX.Both
weights='uniform'andweights='distance'are supported. Single-output and multi-output estimators are supported.For
weights='distance', each in-radius neighbour is weighted by1 / max(distance, 1e-12). When a query point coincides with a training point (distance ≈ 0), that training point’s vote dominates.For multi-output estimators (
_y.shape[1] > 1), each output is predicted independently. Only the predicted labels are returned (probability output is not available in multi-output mode).Supported metrics are the same as for
yobx.sklearn.neighbors.kneighbors.sklearn_knn_classifier()(seeyobx.sklearn.neighbors.kneighbors._compute_pairwise_distances()).- Parameters:
g – graph builder
sts – shapes defined by scikit-learn
outputs – desired output names;
outputs[0]receives the predicted labels andoutputs[1](if present) receives the class probabilities (single-output mode only).estimator – a fitted
RadiusNeighborsClassifierX – input tensor name
name – prefix for node names
- Returns:
predicted label tensor (and optionally probability tensor for single-output estimators)
- Raises:
NotImplementedError – if opset < 13
- yobx.sklearn.neighbors.radiusneighbors.sklearn_radius_neighbors_regressor(g: GraphBuilderExtendedProtocol, sts: Dict, outputs: List[str], estimator: RadiusNeighborsRegressor, X: str, name: str = 'rnn_reg') str[source]#
Converts a
sklearn.neighbors.RadiusNeighborsRegressorinto ONNX.Both
weights='uniform'andweights='distance'are supported. Single-output and multi-output estimators are supported.For
weights='distance', each in-radius neighbour is weighted by1 / max(distance, 1e-12). When a query point coincides with a training point (distance ≈ 0), that training point’s weight dominates.For multi-output estimators (
_y.shape[1] > 1), the prediction is a(N, n_targets)tensor.For query points with no neighbour within the radius the prediction is
NaN(float division0 / 0for uniform, or0 / 0for distance weights), which mirrors the fact that sklearn raisesValueErrorfor such points at runtime.Supported metrics are the same as for
yobx.sklearn.neighbors.kneighbors.sklearn_knn_regressor()(seeyobx.sklearn.neighbors.kneighbors._compute_pairwise_distances()).- Parameters:
g – graph builder
sts – shapes defined by scikit-learn
outputs – desired output names
estimator – a fitted
RadiusNeighborsRegressorX – input tensor name
name – prefix for node names
- Returns:
predicted value tensor — shape
(N,)for single-output or(N, n_targets)for multi-output estimators- Raises:
NotImplementedError – if opset < 13