Skip to content
generated from Jeff-Tian/find-s

calculates information entropy, and information gains.

License

Notifications You must be signed in to change notification settings

Jeff-Tian/entropy

Repository files navigation

entropy-ts

信息熵,使用 TypeScript 实现。

Git commit with emojis! 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

Sponsor this project

Packages

No packages published