DocumentationClassesDistanceMetric

Class: DistanceMetric

Uniform interface for fast distance metric functions.

The DistanceMetric class provides a convenient way to compute pairwise distances between samples. It supports various distance metrics, such as Euclidean distance, Manhattan distance, and more.

The pairwise method can be used to compute pairwise distances between samples in the input arrays. It returns a distance matrix representing the distances between all pairs of samples.

The get_metric method allows you to retrieve a specific metric using its string identifier.

Examples

Python Reference

Constructors

new DistanceMetric()

new DistanceMetric(opts?): DistanceMetric

Parameters

ParameterTypeDescription
opts?object-
opts.dtype?anyThe data type of the input on which the metric will be applied. This affects the precision of the computed distances. By default, it is set to np.float64.
opts.kwargs?anyAdditional keyword arguments that will be passed to the requested metric. These arguments can be used to customize the behavior of the specific metric.
opts.metric?stringThe string identifier or class name of the desired distance metric. See the documentation of the DistanceMetric class for a list of available metrics.

Returns DistanceMetric

Defined in generated/metrics/DistanceMetric.ts:29

Properties

PropertyTypeDefault valueDefined in
_isDisposedbooleanfalsegenerated/metrics/DistanceMetric.ts:27
_isInitializedbooleanfalsegenerated/metrics/DistanceMetric.ts:26
_pyPythonBridgeundefinedgenerated/metrics/DistanceMetric.ts:25
idstringundefinedgenerated/metrics/DistanceMetric.ts:22
optsanyundefinedgenerated/metrics/DistanceMetric.ts:23

Accessors

metric_obj

Get Signature

get metric_obj(): Promise<any>

An instance of the requested distance metric class.

Returns Promise<any>

Defined in generated/metrics/DistanceMetric.ts:162


py

Get Signature

get py(): PythonBridge

Returns PythonBridge

Set Signature

set py(pythonBridge): void

Parameters

ParameterType
pythonBridgePythonBridge

Returns void

Defined in generated/metrics/DistanceMetric.ts:49

Methods

dispose()

dispose(): Promise<void>

Disposes of the underlying Python resources.

Once dispose() is called, the instance is no longer usable.

Returns Promise<void>

Defined in generated/metrics/DistanceMetric.ts:101


get_metric()

get_metric(opts): Promise<any>

Get the given distance metric from the string identifier.

See the docstring of DistanceMetric for a list of available metrics.

Parameters

ParameterTypeDescription
optsobject-
opts.dtype?anyThe data type of the input on which the metric will be applied. This affects the precision of the computed distances. By default, it is set to np.float64.
opts.kwargs?anyAdditional keyword arguments that will be passed to the requested metric. These arguments can be used to customize the behavior of the specific metric.
opts.metric?stringThe string identifier or class name of the desired distance metric. See the documentation of the DistanceMetric class for a list of available metrics.

Returns Promise<any>

Defined in generated/metrics/DistanceMetric.ts:120


init()

init(py): Promise<void>

Initializes the underlying Python resources.

This instance is not usable until the Promise returned by init() resolves.

Parameters

ParameterType
pyPythonBridge

Returns Promise<void>

Defined in generated/metrics/DistanceMetric.ts:62