Miss any of our Open RFC calls?Watch the recordings here! »

furlong

0.2.5 • Public • Published

furlong

A zero dependency Node and Javascript library for computing pairwise distance metrics.

Build Status

Installation

npm install furlong --save

Usage

furlong can be used with Node or with plain Javascript; it has no external dependencies. To use with Node, simply require it:
const { furlong } = require('furlong')

To use in Javascript, just import it:
import { furlong } from 'furlong'

Pairwise distance functions are computed using a distance method. furlong provides several built-in distances functions and also supports user defined functions. The provided distance functions include:

  • Euclidean distance
  • Manhattan (Taxicab) distance
  • Chebyshev distance
  • Bray Curtis distance
  • Canberra distance
  • Hamming distance
>>> furlong('euclidean').distance([0,0,0],[0,0,100])
100

Accessor functions can also be used for more complex data structures:

>>> const distanceFunc = furlong('chebyshev')
                     .x(d => d.foo)
                     .y(d => d.bar)

>>> const vectorA = [{'foo': 12},{'foo': 7},{'foo': 0}]
>>> const vectorB = [{'bar': 6},{'bar': 32},{'bar': 27}]
>>> distanceFunc
      .distance(vectorA, vectorB)
      .toFixed(2)
27

Custom distance functions can be used with furlongs accessors as well:

>>> const customDistanceFunc = (v1, v2) => 0
>>> furlong('hamming')
    .func(customDistanceFunc)
    .distance([0,0],[1,1])
0

Testing

  • Using npm:
    npm test

Release History

  • 0.1.0 Initial release
  • 0.2.0 Ported library to Typescript

Install

npm i furlong

DownloadsWeekly Downloads

0

Version

0.2.5

License

none

Unpacked Size

8.6 kB

Total Files

9

Last publish

Collaborators

  • avatar