Socket
Socket
Sign inDemoInstall

ml-distance

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ml-distance

Distance and similarity functions to compare vectors


Version published
Weekly downloads
276K
decreased by-4.22%
Maintainers
1
Weekly downloads
 
Created

What is ml-distance?

The ml-distance npm package provides a collection of functions to calculate various types of distances between vectors. It is useful for tasks in machine learning, data analysis, and other fields where measuring similarity or dissimilarity between data points is important.

What are ml-distance's main functionalities?

Euclidean Distance

Calculates the Euclidean distance between two vectors. This is the straight-line distance in Euclidean space.

const distance = require('ml-distance');
const euclidean = distance.euclidean([1, 2], [4, 6]);
console.log(euclidean); // Output: 5

Manhattan Distance

Calculates the Manhattan distance between two vectors. This is the sum of the absolute differences of their Cartesian coordinates.

const distance = require('ml-distance');
const manhattan = distance.manhattan([1, 2], [4, 6]);
console.log(manhattan); // Output: 7

Cosine Similarity

Calculates the cosine similarity between two vectors. This measures the cosine of the angle between them, which is useful for determining how similar two vectors are.

const distance = require('ml-distance');
const cosine = distance.cosine([1, 2], [4, 6]);
console.log(cosine); // Output: 0.9838699100999074

Jaccard Index

Calculates the Jaccard index between two sets. This is the size of the intersection divided by the size of the union of the sets.

const distance = require('ml-distance');
const jaccard = distance.jaccard([1, 2, 3], [2, 3, 4]);
console.log(jaccard); // Output: 0.5

Other packages similar to ml-distance

Keywords

FAQs

Package last updated on 18 Nov 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc