Skip to main content

Python module of less-common metrics.

Project description


Python implementation of some more uncommon metrics. Currently only longest common subsequence LCS metrics are implemented.


This package requires the following python libraries:

  1. numpy (automatically installed when package is installed via pip)


The metrics package can be installed directly from pip.

pip3 install distance-metrics


The metrics library currently has support for the following modules.

  1. Longest common subsequence metrics distance_metrics.lcs

Longest common subsequence metrics

The LCS module currently implements 2 distances:

  1. Length of longest common subsequence (distance_metrics.lcs.llcs(u, v)).
  2. Bakkelund distance [1] (metrics.lcs.bakkelund(u, v))


# Imports
from distance_metrics import lcs
import numpy as np

# Create example input arrays
u = np.random.choice(list('ABCD'), size=20)
v = np.random.choice(list('BCDE'), size=20)

# Compute metrics
llcs      = lcs.llcs(u, v)
bakkelund = lcs.bakkelund(u, v)

# Print values
print("LLCS     : {}".format(llcs))
print("Bakkelund: {}".format(bakkelund))
1 Bakkelund, D. (2009). An LCS-based string metric. Olso, Norway: University of Oslo.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

distance-metrics-0.0.2.tar.gz (3.0 kB view hashes)

Uploaded source

Built Distribution

distance_metrics-0.0.2-py3-none-any.whl (4.9 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page