Documentation
Classes
RadiusNeighborsTransformer

RadiusNeighborsTransformer

Transform X into a (weighted) graph of neighbors nearer than a radius.

The transformed data is a sparse graph as returned by radius\_neighbors\_graph.

Read more in the User Guide.

Python Reference (opens in a new tab)

Constructors

constructor()

Signature

new RadiusNeighborsTransformer(opts?: object): RadiusNeighborsTransformer;

Parameters

NameTypeDescription
opts?object-
opts.algorithm?"auto" | "ball_tree" | "kd_tree" | "brute"Algorithm used to compute the nearest neighbors: Default Value 'auto'
opts.leaf_size?numberLeaf size passed to BallTree or KDTree. This can affect the speed of the construction and query, as well as the memory required to store the tree. The optimal value depends on the nature of the problem. Default Value 30
opts.metric?stringMetric to use for distance computation. Default is “minkowski”, which results in the standard Euclidean distance when p = 2. See the documentation of scipy.spatial.distance (opens in a new tab) and the metrics listed in distance\_metrics for valid metric values. If metric is a callable function, it takes two arrays representing 1D vectors as inputs and must return one value indicating the distance between those vectors. This works for Scipy’s metrics, but is less efficient than passing the metric name as a string. Distance matrices are not supported. Default Value 'minkowski'
opts.metric_params?anyAdditional keyword arguments for the metric function.
opts.mode?"connectivity" | "distance"Type of returned matrix: ‘connectivity’ will return the connectivity matrix with ones and zeros, and ‘distance’ will return the distances between neighbors according to the given metric. Default Value 'distance'
opts.n_jobs?numberThe number of parallel jobs to run for neighbors search. If \-1, then the number of jobs is set to the number of CPU cores.
opts.p?numberParameter for the Minkowski metric from sklearn.metrics.pairwise.pairwise_distances. When p = 1, this is equivalent to using manhattan_distance (l1), and euclidean_distance (l2) for p = 2. For arbitrary p, minkowski_distance (l_p) is used. Default Value 2
opts.radius?numberRadius of neighborhood in the transformed sparse graph. Default Value 1

Returns

RadiusNeighborsTransformer

Defined in: generated/neighbors/RadiusNeighborsTransformer.ts:25 (opens in a new tab)

Methods

dispose()

Disposes of the underlying Python resources.

Once dispose() is called, the instance is no longer usable.

Signature

dispose(): Promise<void>;

Returns

Promise<void>

Defined in: generated/neighbors/RadiusNeighborsTransformer.ts:149 (opens in a new tab)

fit()

Fit the radius neighbors transformer from the training dataset.

Signature

fit(opts: object): Promise<any>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLikeTraining data.
opts.y?anyNot used, present for API consistency by convention.

Returns

Promise<any>

Defined in: generated/neighbors/RadiusNeighborsTransformer.ts:166 (opens in a new tab)

fit_transform()

Fit to data, then transform it.

Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.

Signature

fit_transform(opts: object): Promise<any[]>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLike[]Training set.
opts.y?anyNot used, present for API consistency by convention.

Returns

Promise<any[]>

Defined in: generated/neighbors/RadiusNeighborsTransformer.ts:210 (opens in a new tab)

get_feature_names_out()

Get output feature names for transformation.

The feature names out will prefixed by the lowercased class name. For example, if the transformer outputs 3 features, then the feature names out are: \["class\_name0", "class\_name1", "class\_name2"\].

Signature

get_feature_names_out(opts: object): Promise<any>;

Parameters

NameTypeDescription
optsobject-
opts.input_features?anyOnly used to validate feature names with the names seen in fit.

Returns

Promise<any>

Defined in: generated/neighbors/RadiusNeighborsTransformer.ts:255 (opens in a new tab)

get_metadata_routing()

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Signature

get_metadata_routing(opts: object): Promise<any>;

Parameters

NameTypeDescription
optsobject-
opts.routing?anyA MetadataRequest encapsulating routing information.

Returns

Promise<any>

Defined in: generated/neighbors/RadiusNeighborsTransformer.ts:295 (opens in a new tab)

init()

Initializes the underlying Python resources.

This instance is not usable until the Promise returned by init() resolves.

Signature

init(py: PythonBridge): Promise<void>;

Parameters

NameType
pyPythonBridge

Returns

Promise<void>

Defined in: generated/neighbors/RadiusNeighborsTransformer.ts:99 (opens in a new tab)

radius_neighbors()

Find the neighbors within a given radius of a point or points.

Return the indices and distances of each point from the dataset lying in a ball with size radius around the points of the query array. Points lying on the boundary are included in the results.

The result points are not necessarily sorted by distance to their query point.

Signature

radius_neighbors(opts: object): Promise<any>;

Parameters

NameTypeDescription
optsobject-
opts.X?anyThe query point or points. If not provided, neighbors of each indexed point are returned. In this case, the query point is not considered its own neighbor.
opts.radius?numberLimiting distance of neighbors to return. The default is the value passed to the constructor.
opts.return_distance?booleanWhether or not to return the distances. Default Value true
opts.sort_results?booleanIf true, the distances and indices will be sorted by increasing distances before being returned. If false, the results may not be sorted. If return\_distance=False, setting sort\_results=True will result in an error. Default Value false

Returns

Promise<any>

Defined in: generated/neighbors/RadiusNeighborsTransformer.ts:337 (opens in a new tab)

radius_neighbors_graph()

Compute the (weighted) graph of Neighbors for points in X.

Neighborhoods are restricted the points at a distance lower than radius.

Signature

radius_neighbors_graph(opts: object): Promise<any[]>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLikeThe query point or points. If not provided, neighbors of each indexed point are returned. In this case, the query point is not considered its own neighbor.
opts.mode?"connectivity" | "distance"Type of returned matrix: ‘connectivity’ will return the connectivity matrix with ones and zeros, in ‘distance’ the edges are distances between points, type of distance depends on the selected metric parameter in NearestNeighbors class. Default Value 'connectivity'
opts.radius?numberRadius of neighborhoods. The default is the value passed to the constructor.
opts.sort_results?booleanIf true, in each row of the result, the non-zero entries will be sorted by increasing distances. If false, the non-zero entries may not be sorted. Only used with mode=’distance’. Default Value false

Returns

Promise<any[]>

Defined in: generated/neighbors/RadiusNeighborsTransformer.ts:397 (opens in a new tab)

set_output()

Set output container.

See Introducing the set_output API for an example on how to use the API.

Signature

set_output(opts: object): Promise<any>;

Parameters

NameTypeDescription
optsobject-
opts.transform?"default" | "pandas"Configure output of transform and fit\_transform.

Returns

Promise<any>

Defined in: generated/neighbors/RadiusNeighborsTransformer.ts:460 (opens in a new tab)

transform()

Compute the (weighted) graph of Neighbors for points in X.

Signature

transform(opts: object): Promise<any[]>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLike[]Sample data.

Returns

Promise<any[]>

Defined in: generated/neighbors/RadiusNeighborsTransformer.ts:498 (opens in a new tab)

Properties

_isDisposed

boolean = false

Defined in: generated/neighbors/RadiusNeighborsTransformer.ts:23 (opens in a new tab)

_isInitialized

boolean = false

Defined in: generated/neighbors/RadiusNeighborsTransformer.ts:22 (opens in a new tab)

_py

PythonBridge

Defined in: generated/neighbors/RadiusNeighborsTransformer.ts:21 (opens in a new tab)

id

string

Defined in: generated/neighbors/RadiusNeighborsTransformer.ts:18 (opens in a new tab)

opts

any

Defined in: generated/neighbors/RadiusNeighborsTransformer.ts:19 (opens in a new tab)

Accessors

effective_metric_

The distance metric used. It will be same as the metric parameter or a synonym of it, e.g. ‘euclidean’ if the metric parameter set to ‘minkowski’ and p parameter set to 2.

Signature

effective_metric_(): Promise<string>;

Returns

Promise<string>

Defined in: generated/neighbors/RadiusNeighborsTransformer.ts:536 (opens in a new tab)

effective_metric_params_

Additional keyword arguments for the metric function. For most metrics will be same with metric\_params parameter, but may also contain the p parameter value if the effective\_metric\_ attribute is set to ‘minkowski’.

Signature

effective_metric_params_(): Promise<any>;

Returns

Promise<any>

Defined in: generated/neighbors/RadiusNeighborsTransformer.ts:563 (opens in a new tab)

feature_names_in_

Names of features seen during fit. Defined only when X has feature names that are all strings.

Signature

feature_names_in_(): Promise<ArrayLike>;

Returns

Promise<ArrayLike>

Defined in: generated/neighbors/RadiusNeighborsTransformer.ts:617 (opens in a new tab)

n_features_in_

Number of features seen during fit.

Signature

n_features_in_(): Promise<number>;

Returns

Promise<number>

Defined in: generated/neighbors/RadiusNeighborsTransformer.ts:590 (opens in a new tab)

n_samples_fit_

Number of samples in the fitted data.

Signature

n_samples_fit_(): Promise<number>;

Returns

Promise<number>

Defined in: generated/neighbors/RadiusNeighborsTransformer.ts:644 (opens in a new tab)

py

Signature

py(): PythonBridge;

Returns

PythonBridge

Defined in: generated/neighbors/RadiusNeighborsTransformer.ts:86 (opens in a new tab)

Signature

py(pythonBridge: PythonBridge): void;

Parameters

NameType
pythonBridgePythonBridge

Returns

void

Defined in: generated/neighbors/RadiusNeighborsTransformer.ts:90 (opens in a new tab)