utils.dist_metrics

The hbbrain.utils.dist_metrics submodule implements various functions to compute distance-based metrics.

hbbrain.utils.dist_metrics.manhattan_distance(X, Y)[source]

Compute Manhattan distance between two points X and Y

Parameters:
Xndarray of shape (n_features,) or (n_samples, n_features)

Vector or matrix contains the coordinates of the first point.

Yndarray of shape (n_features,) or (n_samples, n_features)

Vector or matrix contains the coordinates of the second point.

Returns:
dfloat or ndarray of shape (n_samples,)

A scalar value or a vector stores the resulting Manhattan distance values.

hbbrain.utils.dist_metrics.manhattan_distance_with_missing_val(X1, X2, Y1, Y2)[source]

Compute Manhattan distance between the central points of X1, X2 and Y1, Y2.

Note

X1, X2, Y1, Y2 can contain missing values. In that case, X1j=1+EPSILON_MISSING_VAL > X2j=-EPSILON_MISSING_VAL and Y1j=1+EPSILON_MISSING_VAL > Y2j=-EPSILON_MISSING_VAL. The Manhattan distance is only computed for the dimensions without missing values.

Parameters:
X1ndarray of shape (n_features,) or (n_samples, n_features)

Vector or matrix contains the lower bounds of the first point.

X2ndarray of shape (n_features,) or (n_samples, n_features)

Vector or matrix contains the upper bounds of the first point.

Y1ndarray of shape (n_features,) or (n_samples, n_features)

Vector or matrix contains the lower bounds of the second point.

Y2ndarray of shape (n_features,) or (n_samples, n_features)

Vector or matrix contains the upper bounds of the second point.

Returns:
resultndarray of shape (n_samples,)

A vector stores the resulting Manhattan distance values.

hbbrain.utils.dist_metrics.manhattan_distance_with_missing_val_free_range(X1, X2, Y1, Y2, MIN_RANGE, MAX_RANGE)[source]

Compute Manhattan distance between the central points of X1, X2 and Y1, Y2. The coordinates are not limited by ranges.

Note

X1, X2, Y1, Y2 can contain missing values. In that case, X1j=MAX_RANGE > X2j=MIN_RANGE and Y1j=MAX_RANGE > Y2j=MIN_RANGE. The Manhattan distance is only computed for the dimensions without missing values.

Parameters:
X1ndarray of shape (n_features,) or (n_samples, n_features)

Vector or matrix contains the lower bounds of the first point.

X2ndarray of shape (n_features,) or (n_samples, n_features)

Vector or matrix contains the upper bounds of the first point.

Y1ndarray of shape (n_features,) or (n_samples, n_features)

Vector or matrix contains the lower bounds of the second point.

Y2ndarray of shape (n_features,) or (n_samples, n_features)

Vector or matrix contains the upper bounds of the second point.

MIN_RANGEfloat

The minimum value of floating numbers for missing features.

MAX_RANGEfloat

The maximum values of floating numbers for missing features.

Returns:
resultndarray of shape (n_samples,)

A vector stores the resulting Manhattan distance values.

hbbrain.utils.dist_metrics.rfmnn_distance(X, V, W)[source]

Compute the distance from the input pattern to the list of existing hyperboxes represented by minimum points V and maximum points W.

Parameters:
Xndarray of shape (n_features,) or (n_hyperboxes, n_features)

Vector or matrix contains the coordinates of the input pattern.

Vndarray of shape (n_hyperboxes, n_features)

Lower bounds of all existing hyperboxes.

Wndarray of shape (n_hyperboxes, n_features)

Upper bounds of all existing hyperboxes.

Returns:
distndarray of shape (n_hyperboxes,)

The distance values from the input pattern to all existing hyperboxes.