entropy-ts
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

entropy-ts

信息熵,使用 TypeScript 实现。

npm download NPM version Build Status Dependencies Status Coverage Status code style: prettier

信息熵

在机器学习中,熵刻画了任意样例集的纯度。给定包含关于某个目标概念的正反样例的样例集 S,那么 S 相对这个布尔型分类的熵为:

Entropy(S) = -p+log2(p+) - p-log2(p-)

其中,p+是在 S 中正例的比例,p-是在 S 中反例的比例。在有关熵的所有计算中我们定义 0log0 为 0。

安装

npm install entropy-ts

使用

import { entropy } from 'entropy-ts'
 
const samples = [
  '+', '+', '-', '+', '-', '-'
]
 
const res = entropy(samples)
 
assert.deepStrictEqual(res, 1)

开发

  1. 修改代码后跑

    npm test

    确保测试通过。

  2. git commit

  3. npm version patch/minor/major

  4. npm publish

Readme

Keywords

none

Package Sidebar

Install

npm i entropy-ts

Weekly Downloads

2

Version

0.1.0

License

MIT

Unpacked Size

8.22 kB

Total Files

7

Last publish

Collaborators

  • jeff-tian