yobx.sklearn.neighbors.radiusneighbors_transformer#
- yobx.sklearn.neighbors.radiusneighbors_transformer.sklearn_radius_neighbors_transformer(g: GraphBuilderExtendedProtocol, sts: Dict, outputs: List[str], estimator: RadiusNeighborsTransformer, X: str, name: str = 'rnn_transform') str[source]#
Converts a
sklearn.neighbors.RadiusNeighborsTransformerinto ONNX.The converter produces a dense
(N, M)output tensor whereNis the number of query samples andMis the number of training samples.mode='connectivity'— entry(i, j)is1.0when training samplejis within the radius of query pointi, and0.0otherwise.mode='distance'— entry(i, j)is the distance from query pointito training samplejwhenjis within the radius, and0.0otherwise.
Note
sklearn.neighbors.RadiusNeighborsTransformer.transform()returns a sparse CSR matrix. The ONNX graph returns the equivalent dense matrix (i.e. what you would obtain by calling.toarray()on the sparse result).Supported metrics:
"sqeuclidean","euclidean","cosine","manhattan"(aliases:"cityblock","l1"),"chebyshev","minkowski". The"euclidean"and"sqeuclidean"metrics usecom.microsoft.CDistwhen that domain is registered; all other metrics use the standard-ONNX path.Full graph structure (standard-ONNX path):
X (N, F) │ └─── pairwise distances ─────────────────────────────────────► dists (N, M) │ in_radius = (dists <= radius) ──► mask (N, M) bool │ mode='connectivity': Cast(float) ──────────────────────► output (N, M) mode='distance': Where(mask, dists, 0.0) ──────────► output (N, M)- Parameters:
g – graph builder
sts – shapes defined by scikit-learn
outputs – desired output names
estimator – a fitted
RadiusNeighborsTransformerX – input tensor name
name – prefix for node names
- Returns:
output tensor name — dense
(N, M)matrix- Raises:
NotImplementedError – if opset < 13 or the metric is not supported