NaiveNearestNeighbour¶

class
NaiveNearestNeighbour
(*args)¶ Brute force algorithm for nearestneighbour lookup.
Parameters:  sample : 2d sequence of float
Points.
See also
Notes
This algorithm compares distance to all points in input sample. It can be used when sample size is very small, or in high dimension. In other cases, KDTree is much faster.
Examples
>>> import openturns as ot >>> sample = ot.Normal(2).getSample(10) >>> tree = ot.NaiveNearestNeighbour(sample) >>> neighbour = sample[tree.query([0.1, 0.2])]
Methods
getClassName
()Accessor to the object’s name. getId
()Accessor to the object’s id. getName
()Accessor to the object’s name. getSample
()Get the points which have been used to build this nearest neighbour algorithm. getShadowedId
()Accessor to the object’s shadowed id. getVisibility
()Accessor to the object’s visibility state. hasName
()Test if the object is named. hasVisibleName
()Test if the object has a distinguishable name. query
(*args)Get the index of the nearest neighbour of the given point. queryK
(x, k[, sorted])Get the indices of nearest neighbours of the given point. setName
(name)Accessor to the object’s name. setSample
(sample)Build a NearestNeighbourAlgorithm from these points. setShadowedId
(id)Accessor to the object’s shadowed id. setVisibility
(visible)Accessor to the object’s visibility state. 
__init__
(*args)¶ Initialize self. See help(type(self)) for accurate signature.

getClassName
()¶ Accessor to the object’s name.
Returns:  class_name : str
The object class name (object.__class__.__name__).

getId
()¶ Accessor to the object’s id.
Returns:  id : int
Internal unique identifier.

getName
()¶ Accessor to the object’s name.
Returns:  name : str
The name of the object.

getSample
()¶ Get the points which have been used to build this nearest neighbour algorithm.
Returns:  sample :
Sample
Input points.
 sample :

getShadowedId
()¶ Accessor to the object’s shadowed id.
Returns:  id : int
Internal unique identifier.

getVisibility
()¶ Accessor to the object’s visibility state.
Returns:  visible : bool
Visibility flag.

hasName
()¶ Test if the object is named.
Returns:  hasName : bool
True if the name is not empty.

hasVisibleName
()¶ Test if the object has a distinguishable name.
Returns:  hasVisibleName : bool
True if the name is not empty and not the default one.

query
(*args)¶ Get the index of the nearest neighbour of the given point.
 Available usages:
query(point)
query(sample)
Parameters:  point : sequence of float
Given point.
 sample : 2d sequence of float
Given points.
Returns:  index : int
Index of the nearest neighbour of the given point.
 indices :
openturns.Indices
Index of the nearest neighbour of the given points.

queryK
(x, k, sorted=False)¶ Get the indices of nearest neighbours of the given point.
Parameters:  x : sequence of float
Given point.
 k : int
Number of indices to return.
 sorted : bool, optional
Boolean to tell whether returned indices are sorted according to the distance to the given point.
Returns:  indices : sequence of int
Indices of the k nearest neighbours of the given point.

setName
(name)¶ Accessor to the object’s name.
Parameters:  name : str
The name of the object.

setSample
(sample)¶ Build a NearestNeighbourAlgorithm from these points.
Parameters:  sample :
Sample
Input points.
 sample :

setShadowedId
(id)¶ Accessor to the object’s shadowed id.
Parameters:  id : int
Internal unique identifier.

setVisibility
(visible)¶ Accessor to the object’s visibility state.
Parameters:  visible : bool
Visibility flag.