mirror of https://github.com/vladmandic/human
parent
6a8806585c
commit
333457d935
|
@ -38,10 +38,12 @@ They can be stored as normal arrays and reused as needed
|
||||||
|
|
||||||
Simmilarity function is based on *Eucilidean distance* between all points in vector
|
Simmilarity function is based on *Eucilidean distance* between all points in vector
|
||||||
*Eucliean distance is limited case of Minkowski distance with order of 2*
|
*Eucliean distance is limited case of Minkowski distance with order of 2*
|
||||||
*[Minkowski distance](https://en.wikipedia.org/wiki/Minkowski_distance) is a nth root of sum of nth powers of distances between each point in (each value in 192-member array)*
|
*[Minkowski distance](https://en.wikipedia.org/wiki/Minkowski_distance) is a nth root of sum of nth powers of distances between each point (each value in 192-member array)*
|
||||||
|
|
||||||
Changing `order` can make simmilarity matching more or less sensitive:
|
Changing `order` can make simmilarity matching more or less sensitive:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const distance = ((firstEmbedding.map((val, i) => (val - secondEmbedding[i])).reduce((dist, diff) => dist + (diff ** order), 0) ** (1 / order)));
|
const distance = ((firstEmbedding.map((val, i) => (val - secondEmbedding[i])).reduce((dist, diff) => dist + (diff ** order), 0) ** (1 / order)));
|
||||||
```
|
```
|
||||||
|
|
||||||
|
*Once embedding values are calculated and stored, if you want to use stored embedding values without requiring `Human` library you can use above formula to calculate simmilarity on the fly.*
|
||||||
|
|
Loading…
Reference in New Issue