Regression based on neighbors within a fixed radius.
The target is predicted by local interpolation of the targets associated of the nearest neighbors in the training set.
Read more in the User Guide.
new RadiusNeighborsRegressor(opts?: object): RadiusNeighborsRegressor;
Name | Type | Description |
---|---|---|
opts? |
object |
- |
opts.algorithm? |
"auto" | "ball_tree" | "kd_tree" | "brute" |
Algorithm used to compute the nearest neighbors: Default Value 'auto' |
opts.leaf_size? |
number |
Leaf 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? |
string |
Metric 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 and the metrics listed in distance\_metrics for valid metric values. If metric is “precomputed”, X is assumed to be a distance matrix and must be square during fit. X may be a sparse graph, in which case only “nonzero” elements may be considered neighbors. 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. Default Value 'minkowski' |
opts.metric_params? |
any |
Additional keyword arguments for the metric function. |
opts.n_jobs? |
number |
The number of parallel jobs to run for neighbors search. undefined means 1 unless in a joblib.parallel\_backend context. \-1 means using all processors. See Glossary for more details. |
opts.p? |
number |
Power parameter for the Minkowski metric. 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? |
number |
Range of parameter space to use by default for radius\_neighbors queries. Default Value 1 |
opts.weights? |
"uniform" | "distance" |
Weight function used in prediction. Possible values: Default Value 'uniform' |
Defined in: generated/neighbors/RadiusNeighborsRegressor.ts:25
Disposes of the underlying Python resources.
Once dispose()
is called, the instance is no longer usable.
dispose(): Promise<void>;
Promise
<void
>
Defined in: generated/neighbors/RadiusNeighborsRegressor.ts:149
Fit the radius neighbors regressor from the training dataset.
fit(opts: object): Promise<any>;
Name | Type | Description |
---|---|---|
opts |
object |
- |
opts.X? |
ArrayLike |
Training data. |
opts.y? |
any |
Target values. |
Promise
<any
>
Defined in: generated/neighbors/RadiusNeighborsRegressor.ts:166
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
get_metadata_routing(opts: object): Promise<any>;
Name | Type | Description |
---|---|---|
opts |
object |
- |
opts.routing? |
any |
A MetadataRequest encapsulating routing information. |
Promise
<any
>
Defined in: generated/neighbors/RadiusNeighborsRegressor.ts:210
Initializes the underlying Python resources.
This instance is not usable until the Promise
returned by init()
resolves.
init(py: PythonBridge): Promise<void>;
Name | Type |
---|---|
py |
PythonBridge |
Promise
<void
>
Defined in: generated/neighbors/RadiusNeighborsRegressor.ts:99
Predict the target for the provided data.
predict(opts: object): Promise<ArrayLike>;
Name | Type | Description |
---|---|---|
opts |
object |
- |
opts.X? |
any |
Test samples. |
Promise
<ArrayLike
>
Defined in: generated/neighbors/RadiusNeighborsRegressor.ts:248
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.
radius_neighbors(opts: object): Promise<any>;
Name | Type | Description |
---|---|---|
opts |
object |
- |
opts.X? |
any |
The 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? |
number |
Limiting distance of neighbors to return. The default is the value passed to the constructor. |
opts.return_distance? |
boolean |
Whether or not to return the distances. Default Value true |
opts.sort_results? |
boolean |
If 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 |
Promise
<any
>
Defined in: generated/neighbors/RadiusNeighborsRegressor.ts:289
Compute the (weighted) graph of Neighbors for points in X.
Neighborhoods are restricted the points at a distance lower than radius.
radius_neighbors_graph(opts: object): Promise<any[]>;
Name | Type | Description |
---|---|---|
opts |
object |
- |
opts.X? |
ArrayLike |
The 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? |
number |
Radius of neighborhoods. The default is the value passed to the constructor. |
opts.sort_results? |
boolean |
If 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 |
Promise
<any
[]>
Defined in: generated/neighbors/RadiusNeighborsRegressor.ts:349
Return the coefficient of determination of the prediction.
The coefficient of determination \(R^2\) is defined as \((1 - \frac{u}{v})\), where \(u\) is the residual sum of squares ((y\_true \- y\_pred)\*\* 2).sum()
and \(v\) is the total sum of squares ((y\_true \- y\_true.mean()) \*\* 2).sum()
. The best possible score is 1.0 and it can be negative (because the model can be arbitrarily worse). A constant model that always predicts the expected value of y
, disregarding the input features, would get a \(R^2\) score of 0.0.
score(opts: object): Promise<number>;
Name | Type | Description |
---|---|---|
opts |
object |
- |
opts.X? |
ArrayLike [] |
Test samples. For some estimators this may be a precomputed kernel matrix or a list of generic objects instead with shape (n\_samples, n\_samples\_fitted) , where n\_samples\_fitted is the number of samples used in the fitting for the estimator. |
opts.sample_weight? |
ArrayLike |
Sample weights. |
opts.y? |
ArrayLike |
True values for X . |
Promise
<number
>
Defined in: generated/neighbors/RadiusNeighborsRegressor.ts:412
Request metadata passed to the score
method.
Note that this method is only relevant if enable\_metadata\_routing=True
(see sklearn.set\_config
). Please see User Guide on how the routing mechanism works.
The options for each parameter are:
set_score_request(opts: object): Promise<any>;
Name | Type | Description |
---|---|---|
opts |
object |
- |
opts.sample_weight? |
string | boolean |
Metadata routing for sample\_weight parameter in score . |
Promise
<any
>
Defined in: generated/neighbors/RadiusNeighborsRegressor.ts:467
boolean
=false
Defined in: generated/neighbors/RadiusNeighborsRegressor.ts:23
boolean
=false
Defined in: generated/neighbors/RadiusNeighborsRegressor.ts:22
PythonBridge
Defined in: generated/neighbors/RadiusNeighborsRegressor.ts:21
string
Defined in: generated/neighbors/RadiusNeighborsRegressor.ts:18
any
Defined in: generated/neighbors/RadiusNeighborsRegressor.ts:19
The distance metric to use. 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.
effective_metric_(): Promise<string>;
Promise
<string
>
Defined in: generated/neighbors/RadiusNeighborsRegressor.ts:505
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’.
effective_metric_params_(): Promise<any>;
Promise
<any
>
Defined in: generated/neighbors/RadiusNeighborsRegressor.ts:532
Names of features seen during fit. Defined only when X
has feature names that are all strings.
feature_names_in_(): Promise<ArrayLike>;
Promise
<ArrayLike
>
Defined in: generated/neighbors/RadiusNeighborsRegressor.ts:586
Number of features seen during fit.
n_features_in_(): Promise<number>;
Promise
<number
>
Defined in: generated/neighbors/RadiusNeighborsRegressor.ts:559
Number of samples in the fitted data.
n_samples_fit_(): Promise<number>;
Promise
<number
>
Defined in: generated/neighbors/RadiusNeighborsRegressor.ts:613
py(): PythonBridge;
PythonBridge
Defined in: generated/neighbors/RadiusNeighborsRegressor.ts:86
py(pythonBridge: PythonBridge): void;
Name | Type |
---|---|
pythonBridge |
PythonBridge |
void
Defined in: generated/neighbors/RadiusNeighborsRegressor.ts:90