Distances

All the functions here are functions to find the distance between two pieces of data based on contingency table.

Row 2

Row 1

1

0

1

a

b

0

c

d

Each function has the same parameters and return values:

Parameters
aint

Count of same 1 numbers.

bint

The sum of 1 in row 1 and 0 in row 2.

cint

Sum 1 in row 2 and 0 in row 1.

dint

Count of same 0 numbers.

nint

Sum of all the numbers.

Returns
float

The similarity value between two pieces of data.

besimilarity.distance.bray_curtis(a, b, c, d, n)[source]

Bray-Curtis distance from contingency table.

besimilarity.distance.canberra(a, b, c, d, n)[source]

Canberra distance from contingency table.

besimilarity.distance.chord(a, b, c, d, n)[source]

Chord distance from contingency table.

besimilarity.distance.cityblock(a, b, c, d, n)[source]

Cityblock distance from contingency table.

besimilarity.distance.euclidean(a, b, c, d, n)[source]

Euclidean distance from contingency table.

besimilarity.distance.get_all_functions_name()[source]

Get all the functions in the module.

Returns

List of functions object.

Return type

list

besimilarity.distance.get_function(name)[source]

Get function by name.

Parameters

name (str) – Name of the function.

Returns

Function object.

Return type

function

besimilarity.distance.hamming(a, b, c, d, n)[source]

Hamming coefficient from contingency table.

besimilarity.distance.hellinger(a, b, c, d, n)[source]

Hellinger distance from contingency table.

besimilarity.distance.lance_williams(a, b, c, d, n)[source]

Lance Williams distance from contingency table.

besimilarity.distance.manhattan(a, b, c, d, n)[source]

Manhattan distance from contingency table.

besimilarity.distance.mean_manhattan(a, b, c, d, n)[source]

Mean Manhattan distance from contingency table.

besimilarity.distance.minkowski(a, b, c, d, n)[source]

Minkowski distance from contingency table

besimilarity.distance.pattern_difference(a, b, c, d, n)[source]

Pattern difference from contingency table.

besimilarity.distance.shape_difference(a, b, c, d, n)[source]

Shape difference from contingency table.

besimilarity.distance.size_difference(a, b, c, d, n)[source]

Size difference from contingency table.

besimilarity.distance.squared_euclidean(a, b, c, d, n)[source]

Squared Euclidean distance from contingency table.

besimilarity.distance.vari(a, b, c, d, n)[source]

Vari distance from contingency table.

besimilarity.distance.yuleq(a, b, c, d, n)[source]

Yule-Q distance from contingency table.