package sklearn

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type tag = [
  1. | `KDTree
]
type t = [ `KDTree | `Object ] Obj.t
val of_pyobject : Py.Object.t -> t
val to_pyobject : [> tag ] Obj.t -> Py.Object.t
val kernel_density : ?kernel:string -> ?atol:Py.Object.t -> ?rtol:Py.Object.t -> ?breadth_first:bool -> ?return_log:bool -> x:[> `ArrayLike ] Np.Obj.t -> h:float -> [> tag ] Obj.t -> [> `ArrayLike ] Np.Obj.t

kernel_density(self, X, h, kernel='gaussian', atol=0, rtol=1E-8, breadth_first=True, return_log=False)

Compute the kernel density estimate at points X with the given kernel, using the distance metric specified at tree creation.

Parameters ---------- X : array-like of shape (n_samples, n_features) An array of points to query. Last dimension should match dimension of training data. h : float the bandwidth of the kernel kernel : string specify the kernel to use. Options are

  • 'gaussian'
  • 'tophat'
  • 'epanechnikov'
  • 'exponential'
  • 'linear'
  • 'cosine' Default is kernel = 'gaussian' atol, rtol : float (default = 0) Specify the desired relative and absolute tolerance of the result. If the true result is K_true, then the returned result K_ret satisfies ``abs(K_true - K_ret) < atol + rtol * K_ret`` The default is zero (i.e. machine precision) for both. breadth_first : boolean (default = False) if True, use a breadth-first search. If False (default) use a depth-first search. Breadth-first is generally faster for compact kernels and/or high tolerances. return_log : boolean (default = False) return the logarithm of the result. This can be more accurate than returning the result itself for narrow kernels.

Returns ------- density : ndarray The array of (log)-density evaluations, shape = X.shape:-1

val query_radius : ?count_only:bool -> x:[> `ArrayLike ] Np.Obj.t -> r:Py.Object.t -> [> tag ] Obj.t -> Py.Object.t * Py.Object.t * Py.Object.t

query_radius(self, X, r, count_only = False):

query the tree for neighbors within a radius r

Parameters ---------- X : array-like of shape (n_samples, n_features) An array of points to query r : distance within which neighbors are returned r can be a single value, or an array of values of shape x.shape:-1 if different radii are desired for each point. return_distance : boolean (default = False) if True, return distances to neighbors of each point if False, return only neighbors Note that unlike the query() method, setting return_distance=True here adds to the computation time. Not all distances need to be calculated explicitly for return_distance=False. Results are not sorted by default: see ``sort_results`` keyword. count_only : boolean (default = False) if True, return only the count of points within distance r if False, return the indices of all points within distance r If return_distance==True, setting count_only=True will result in an error. sort_results : boolean (default = False) if True, the distances and indices will be sorted before being returned. If False, the results will not be sorted. If return_distance == False, setting sort_results = True will result in an error.

Returns ------- count : if count_only == True ind : if count_only == False and return_distance == False (ind, dist) : if count_only == False and return_distance == True

count : array of integers, shape = X.shape:-1 each entry gives the number of neighbors within a distance r of the corresponding point.

ind : array of objects, shape = X.shape:-1 each element is a numpy integer array listing the indices of neighbors of the corresponding point. Note that unlike the results of a k-neighbors query, the returned neighbors are not sorted by distance by default.

dist : array of objects, shape = X.shape:-1 each element is a numpy double array listing the distances corresponding to indices in i.

val data : t -> Py.Object.t

Attribute data: get value or raise Not_found if None.

val data_opt : t -> Py.Object.t option

Attribute data: get value as an option.

val to_string : t -> string

Print the object to a human-readable representation.

val show : t -> string

Print the object to a human-readable representation.

val pp : Stdlib.Format.formatter -> t -> unit

Pretty-print the object to a formatter.

OCaml

Innovation. Community. Security.