Class: KernelDensity
Kernel Density Estimation.
Read more in the User Guide.
Constructors
new KernelDensity()
new KernelDensity(
opts
?):KernelDensity
Parameters
Parameter | Type | Description |
---|---|---|
opts ? | object | - |
opts.algorithm ? | "auto" | "ball_tree" | "kd_tree" | The tree algorithm to use. |
opts.atol ? | number | The desired absolute tolerance of the result. A larger tolerance will generally lead to faster execution. |
opts.bandwidth ? | number | "scott" | "silverman" | The bandwidth of the kernel. If bandwidth is a float, it defines the bandwidth of the kernel. If bandwidth is a string, one of the estimation methods is implemented. |
opts.breadth_first ? | boolean | If true (default), use a breadth-first approach to the problem. Otherwise use a depth-first approach. |
opts.kernel ? | "linear" | "cosine" | "exponential" | "gaussian" | "tophat" | "epanechnikov" | The kernel to use. |
opts.leaf_size ? | number | Specify the leaf size of the underlying tree. See BallTree or KDTree for details. |
opts.metric ? | string | Metric to use for distance computation. See the documentation of scipy.spatial.distance and the metrics listed in distance_metrics for valid metric values. Not all metrics are valid with all algorithms: refer to the documentation of BallTree and KDTree . Note that the normalization of the density output is correct only for the Euclidean distance metric. |
opts.metric_params ? | any | Additional parameters to be passed to the tree for use with the metric. For more information, see the documentation of BallTree or KDTree . |
opts.rtol ? | number | The desired relative tolerance of the result. A larger tolerance will generally lead to faster execution. |
Returns KernelDensity
Defined in generated/neighbors/KernelDensity.ts:23
Properties
Property | Type | Default value | Defined in |
---|---|---|---|
_isDisposed | boolean | false | generated/neighbors/KernelDensity.ts:21 |
_isInitialized | boolean | false | generated/neighbors/KernelDensity.ts:20 |
_py | PythonBridge | undefined | generated/neighbors/KernelDensity.ts:19 |
id | string | undefined | generated/neighbors/KernelDensity.ts:16 |
opts | any | undefined | generated/neighbors/KernelDensity.ts:17 |
Accessors
bandwidth_
Get Signature
get bandwidth_():
Promise
<number
>
Value of the bandwidth, given directly by the bandwidth parameter or estimated using the ‘scott’ or ‘silverman’ method.
Returns Promise
<number
>
Defined in generated/neighbors/KernelDensity.ts:463
feature_names_in_
Get Signature
get feature_names_in_():
Promise
<ArrayLike
>
Names of features seen during fit. Defined only when X
has feature names that are all strings.
Returns Promise
<ArrayLike
>
Defined in generated/neighbors/KernelDensity.ts:438
n_features_in_
Get Signature
get n_features_in_():
Promise
<number
>
Number of features seen during fit.
Returns Promise
<number
>
Defined in generated/neighbors/KernelDensity.ts:390
py
Get Signature
get py():
PythonBridge
Returns PythonBridge
Set Signature
set py(
pythonBridge
):void
Parameters
Parameter | Type |
---|---|
pythonBridge | PythonBridge |
Returns void
Defined in generated/neighbors/KernelDensity.ts:97
tree_
Get Signature
get tree_():
Promise
<any
>
The tree algorithm for fast generalized N-point problems.
Returns Promise
<any
>
Defined in generated/neighbors/KernelDensity.ts:415
Methods
dispose()
dispose():
Promise
<void
>
Disposes of the underlying Python resources.
Once dispose()
is called, the instance is no longer usable.
Returns Promise
<void
>
Defined in generated/neighbors/KernelDensity.ts:149
fit()
fit(
opts
):Promise
<any
>
Fit the Kernel Density model on the data.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.sample_weight ? | ArrayLike | List of sample weights attached to the data X. |
opts.X ? | ArrayLike [] | List of n_features-dimensional data points. Each row corresponds to a single data point. |
opts.y ? | any | Ignored. This parameter exists only for compatibility with Pipeline . |
Returns Promise
<any
>
Defined in generated/neighbors/KernelDensity.ts:166
get_metadata_routing()
get_metadata_routing(
opts
):Promise
<any
>
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.routing ? | any | A MetadataRequest encapsulating routing information. |
Returns Promise
<any
>
Defined in generated/neighbors/KernelDensity.ts:210
init()
init(
py
):Promise
<void
>
Initializes the underlying Python resources.
This instance is not usable until the Promise
returned by init()
resolves.
Parameters
Parameter | Type |
---|---|
py | PythonBridge |
Returns Promise
<void
>
Defined in generated/neighbors/KernelDensity.ts:110
sample()
sample(
opts
):Promise
<ArrayLike
[]>
Generate random samples from the model.
Currently, this is implemented only for gaussian and tophat kernels.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.n_samples ? | number | Number of samples to generate. |
opts.random_state ? | number | Determines random number generation used to generate random samples. Pass an int for reproducible results across multiple function calls. See Glossary. |
Returns Promise
<ArrayLike
[]>
Defined in generated/neighbors/KernelDensity.ts:246
score()
score(
opts
):Promise
<number
>
Compute the total log-likelihood under the model.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.X ? | ArrayLike [] | List of n_features-dimensional data points. Each row corresponds to a single data point. |
opts.y ? | any | Ignored. This parameter exists only for compatibility with Pipeline . |
Returns Promise
<number
>
Defined in generated/neighbors/KernelDensity.ts:285
score_samples()
score_samples(
opts
):Promise
<ArrayLike
>
Compute the log-likelihood of each sample under the model.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.X ? | ArrayLike [] | An array of points to query. Last dimension should match dimension of training data (n_features). |
Returns Promise
<ArrayLike
>
Defined in generated/neighbors/KernelDensity.ts:322
set_fit_request()
set_fit_request(
opts
):Promise
<any
>
Request metadata passed to the fit
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:
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.sample_weight ? | string | boolean | Metadata routing for sample_weight parameter in fit . |
Returns Promise
<any
>
Defined in generated/neighbors/KernelDensity.ts:358