Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kongnet/openrarity
openRerity core algorithm JS implementation
https://github.com/kongnet/openrarity
algorithm js openrarity
Last synced: about 2 months ago
JSON representation
openRerity core algorithm JS implementation
- Host: GitHub
- URL: https://github.com/kongnet/openrarity
- Owner: kongnet
- License: mit
- Created: 2022-09-24T14:32:27.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-01-12T07:53:29.000Z (almost 2 years ago)
- Last Synced: 2024-11-13T23:51:37.515Z (about 2 months ago)
- Topics: algorithm, js, openrarity
- Language: JavaScript
- Homepage:
- Size: 25.4 KB
- Stars: 8
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Openrarity
openRerity core algorithm JS implementation
use sky personal js lib## 安装 Install
```js
npm i openrarity
```## 测试 Test
```js
npm test
// normal rank
// same rank
```## 基线测试 Benchmark
```js
npm run benchmark
/* gen Collection items: 100,000 Rarity calc time: 651 ms -- Mac M2{ v: 1.010524265698629, toeknId: 53076, rank: 1 },
{ v: 1.009992300140172, toeknId: 10548, rank: 2 },
'.....',
{ v: 0.9894947869513546, toeknId: 44396, rank: 100000 }
*/```
## 覆盖率 Coverage
```js
npm run cov
/*
----------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
----------------|---------|----------|---------|---------|-------------------
All files | 100 | 100 | 100 | 100 |
----------------|---------|----------|---------|---------|-------------------
*/
```## 测试用例 Test Case
```js
const tokenScore = require('openrarity')let metaData2 = [
{
trait1: 'value1',
trait2: 'value1',
trait3: 'value1'
},
{
trait1: 'value1',
trait2: 'value1',
trait3: 'value1'
},
{
trait1: 'value2',
trait2: 'value1',
trait3: 'value3'
},
{
trait1: 'value2',
trait2: 'value2',
trait3: 'value3'
},
{
trait1: 'value3 ',
trait2: 'value3',
trait3: 'value3'
}
]
let r = tokenScore(metaData2)/*
=>
[
{ v: 1.3926137488801251, toeknId: 4, rank: 1 },
{ v: 1.1338031424711967, toeknId: 3, rank: 2 },
{ v: 0.8749925360622679, toeknId: 0, rank: 3 },
{ v: 0.8749925360622679, toeknId: 1, rank: 3 },
{ v: 0.7235980365241422, toeknId: 2, rank: 4 }
]
*/
```## 算法步骤 Algorithm Step
- Generate trait value map without undefined(blank) trait
- Generate undefined(blank) trait for every token
- Generate trait value stats include traitEntropy
- Generate token trait probability list