Constructor
new BayesianClassifier()
- Source:
Example
var bayes = new BayesianClassifier();
bayes.train({
species: 'Cat'
}, 'animal');
var result = bayes.score({
species: 'Cat'
})
// 结果
// {
// animal: 1
// }
Methods
score(item) → {Object}
计算该项目匹配所有可能类别的概率, 依据其属性进行分类评分。
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
item |
Object
|
格式与 train 方法输入一致的对象 |
Returns:
- Type:
-
Object
返回该项目属于各个类别的概率分布
train(item, category) → {undefined}
使用新项目训练分类器,该项目具有 JavaScript 字面量键值对的单维属性。
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
item |
Object
|
具有一级属性的对象 |
category |
string
|
该项目所属的类别 |
Returns:
- Type:
-
undefined
将项目添加到分类器中