mlpy.knowledgerep.cbr.similarity.NeighborSimilarity¶
-
class
mlpy.knowledgerep.cbr.similarity.
NeighborSimilarity
(n_neighbors=None, radius=None, algorithm=None, metric=None, metric_params=None)[source]¶ Bases:
mlpy.knowledgerep.cbr.similarity.ISimilarity
The neighborhood similarity model.
The neighbor similarity model determines similarity between the data in the indexing structure and the query data by using the nearest neighbor algorithm
sklearn.neighbors.NearestNeighbors
.Both a k-neighbors classifier and a radius-neighbor-classifier are implemented. To choose between the classifiers either n_neighbors or radius must be specified.
Parameters: n_neighbors : int
The number of data points considered to be closest neighbors.
radius : int
The radius around the query data point, within which the data points are considered closest neighbors.
algorithm : str
The internal indexing structure of the training data. Defaults to kd-tree.
metric : str
The metric used to compute the distances between pairs of points. Refer to
sklearn.neighbors.DistanceMetric
for valid identifiers. Default is euclidean.metric_params : dict
Parameters relevant to the specified metric.
Raises: UserWarning :
If the either both or none of n_neighbors and radius are given.
Methods
build_indexing_structure
(data, id_map)Build the indexing structure. compute_similarity
(data_point)Computes the similarity.