https://github.com/mljs/tanimoto
Tanimoto similarity and distance
https://github.com/mljs/tanimoto
Last synced: 2 months ago
JSON representation
Tanimoto similarity and distance
- Host: GitHub
- URL: https://github.com/mljs/tanimoto
- Owner: mljs
- License: mit
- Created: 2015-07-24T13:09:49.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2018-02-22T13:33:32.000Z (over 7 years ago)
- Last Synced: 2024-09-29T05:43:10.023Z (9 months ago)
- Language: JavaScript
- Size: 56.6 KB
- Stars: 4
- Watchers: 13
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: History.md
- License: LICENSE
Awesome Lists containing this project
README
# tanimoto
[![NPM version][npm-image]][npm-url]
[![build status][travis-image]][travis-url]
[![Test coverage][codecov-image]][codecov-url]
[![npm download][download-image]][download-url]Tanimoto similarity and distance methods.
## Installation
`$ npm install --save ml-tanimoto`
## Usage
### Binary
```js
import { binarySimilarity, binaryDistance } from 'ml-tanimoto';const str1 = '1100000011111110010111010110011010100111110100100100110110111110';
const str2 = '0111000100100001100101001001111000000111001001001001010001011101';binarySimilarity(str1, str2) === 0.2549;
binaryDistance(str1, str2) === 0.7451;
```### General values
```js
import { valueSimilarity, valueDistance } from 'ml-tanimoto';const values1 = [true, true, true];
const values2 = [true, false, false];valueSimilarity(values1, values2) === 0.5;
valueDistance(values1, values2) === 0.5;
```### Bit-array values
```js
import { bitArraySimilarity, bitArrayDistance } from 'ml-tanimoto';const values1 = [1, 1, 1];
const values2 = [1, 0, 0];bitArraySimilarity(values1, values2) === 0.333;
bitArrayDistance(values1, values2) === 0.666;
```## [API Documentation](https://mljs.github.io/tanimoto/)
## License
[MIT](./LICENSE)
[npm-image]: https://img.shields.io/npm/v/ml-tanimoto.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/ml-tanimoto
[travis-image]: https://img.shields.io/travis/mljs/tanimoto/master.svg?style=flat-square
[travis-url]: https://travis-ci.org/mljs/tanimoto
[codecov-image]: https://img.shields.io/codecov/c/github/mljs/tanimoto.svg?style=flat-square
[codecov-url]: https://codecov.io/gh/mljs/tanimoto
[download-image]: https://img.shields.io/npm/dm/ml-tanimoto.svg?style=flat-square
[download-url]: https://www.npmjs.com/package/ml-tanimoto