pyclustering.utils.metric Namespace Reference

Module provides various distance metrics - abstraction of the notion of distance in a metric space. More...

## Classes

class  distance_metric
Distance metric performs distance calculation between two points in line with encapsulated function, for example, euclidean distance or chebyshev distance, or even user-defined. More...

class  type_metric
Enumeration of supported metrics in the module for distance calculation between two points. More...

## Functions

def euclidean_distance (point1, point2)
Calculate Euclidean distance between two vectors. More...

def euclidean_distance_numpy (object1, object2)
Calculate Euclidean distance between two objects using numpy. More...

def euclidean_distance_square (point1, point2)
Calculate square Euclidean distance between two vectors. More...

def euclidean_distance_square_numpy (object1, object2)
Calculate square Euclidean distance between two objects using numpy. More...

def manhattan_distance (point1, point2)
Calculate Manhattan distance between between two vectors. More...

def manhattan_distance_numpy (object1, object2)
Calculate Manhattan distance between two objects using numpy. More...

def chebyshev_distance (point1, point2)
Calculate Chebyshev distance between between two vectors. More...

def chebyshev_distance_numpy (object1, object2)
Calculate Chebyshev distance between two objects using numpy. More...

def minkowski_distance (point1, point2, degree=2)
Calculate Minkowski distance between two vectors. More...

def minkowski_distance_numpy (object1, object2, degree=2)
Calculate Minkowski distance between objects using numpy. More...

## Detailed Description

Module provides various distance metrics - abstraction of the notion of distance in a metric space.

Date
2014-2018

## ◆ chebyshev_distance()

 def pyclustering.utils.metric.chebyshev_distance ( point1, point2 )

Calculate Chebyshev distance between between two vectors.

Parameters
 [in] point1 (array_like): The first vector. [in] point2 (array_like): The second vector.
Returns
(double) Chebyshev distance between two vectors.
euclidean_distance_square, euclidean_distance, minkowski_distance

Definition at line 362 of file metric.py.

## ◆ chebyshev_distance_numpy()

 def pyclustering.utils.metric.chebyshev_distance_numpy ( object1, object2 )

Calculate Chebyshev distance between two objects using numpy.

Parameters
 [in] object1 (array_like): The first array_like object. [in] object2 (array_like): The second array_like object.
Returns
(double) Chebyshev distance between two objects.

Definition at line 387 of file metric.py.

## ◆ euclidean_distance()

 def pyclustering.utils.metric.euclidean_distance ( point1, point2 )

Calculate Euclidean distance between two vectors.

The Euclidean between vectors (points) a and b is calculated by following formula:

Where N is a length of each vector.

Parameters
 [in] point1 (array_like): The first vector. [in] point2 (array_like): The second vector.
Returns
(double) Euclidean distance between two vectors.
euclidean_distance_square, manhattan_distance, chebyshev_distance

Definition at line 252 of file metric.py.

## ◆ euclidean_distance_numpy()

 def pyclustering.utils.metric.euclidean_distance_numpy ( object1, object2 )

Calculate Euclidean distance between two objects using numpy.

Parameters
 [in] object1 (array_like): The first array_like object. [in] object2 (array_like): The second array_like object.
Returns
(double) Euclidean distance between two objects.

Definition at line 275 of file metric.py.

## ◆ euclidean_distance_square()

 def pyclustering.utils.metric.euclidean_distance_square ( point1, point2 )

Calculate square Euclidean distance between two vectors.

Parameters
 [in] point1 (array_like): The first vector. [in] point2 (array_like): The second vector.
Returns
(double) Square Euclidean distance between two vectors.
euclidean_distance, manhattan_distance, chebyshev_distance

Definition at line 288 of file metric.py.

Referenced by pyclustering.utils.metric.euclidean_distance().

## ◆ euclidean_distance_square_numpy()

 def pyclustering.utils.metric.euclidean_distance_square_numpy ( object1, object2 )

Calculate square Euclidean distance between two objects using numpy.

Parameters
 [in] object1 (array_like): The first array_like object. [in] object2 (array_like): The second array_like object.
Returns
(double) Square Euclidean distance between two objects.

Definition at line 311 of file metric.py.

## ◆ manhattan_distance()

 def pyclustering.utils.metric.manhattan_distance ( point1, point2 )

Calculate Manhattan distance between between two vectors.

Parameters
 [in] point1 (array_like): The first vector. [in] point2 (array_like): The second vector.
Returns
(double) Manhattan distance between two vectors.
euclidean_distance_square, euclidean_distance, chebyshev_distance

Definition at line 324 of file metric.py.

## ◆ manhattan_distance_numpy()

 def pyclustering.utils.metric.manhattan_distance_numpy ( object1, object2 )

Calculate Manhattan distance between two objects using numpy.

Parameters
 [in] object1 (array_like): The first array_like object. [in] object2 (array_like): The second array_like object.
Returns
(double) Manhattan distance between two objects.

Definition at line 349 of file metric.py.

## ◆ minkowski_distance()

 def pyclustering.utils.metric.minkowski_distance ( point1, point2, degree = 2 )

Calculate Minkowski distance between two vectors.

Parameters
 [in] point1 (array_like): The first vector. [in] point2 (array_like): The second vector. [in] degree (numeric): Degree of that is used for Minkowski distance.
Returns
(double) Minkowski distance between two vectors.
euclidean_distance

Definition at line 400 of file metric.py.

## ◆ minkowski_distance_numpy()

 def pyclustering.utils.metric.minkowski_distance_numpy ( object1, object2, degree = 2 )

Calculate Minkowski distance between objects using numpy.

Parameters
 [in] object1 (array_like): The first array_like object. [in] object2 (array_like): The second array_like object. [in] degree (numeric): Degree of that is used for Minkowski distance.
Returns
(double) Minkowski distance between two object.

Definition at line 424 of file metric.py.