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.

Files for distance-metrics, version 0.0.2
Filename, size File type Python version Upload date Hashes
Filename, size distance_metrics-0.0.2-py3-none-any.whl (4.9 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size distance-metrics-0.0.2.tar.gz (3.0 kB) File type Source Python version None Upload date Hashes View

Supported by

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