naive_bayes
所属分类:聚类算法
开发工具:Dart
文件大小:3KB
下载次数:0
上传日期:2019-01-05 13:13:51
上 传 者:
sh-1993
说明: 一种朴素的Dart贝叶斯分类器
(A Naive-Bayes Classifier for Dart)
文件列表:
LICENSE (101, 2019-01-05)
example (0, 2019-01-05)
example\test.dart (554, 2019-01-05)
lib (0, 2019-01-05)
lib\naive_bayes.dart (3049, 2019-01-05)
pubspec.yaml (298, 2019-01-05)
# `naive_bayes`: A Naive-Bayes Classifier for Dart [WIP]
`naive_bayes` takes a document (piece of text), and tells you what category that document belongs to.
from @[ttezel](https://github.com/ttezel)'s [bayes](https://github.com/ttezel/bayes).js and @[pwlmaciejewski](https://github.com/pwlmaciejewski)'s [pull request](https://github.com/ttezel/bayes/pull/7).
## What can I use this for?
You can use this for categorizing any text content into any arbitrary set of **categories**. For example:
- is an email **spam**, or **not spam** ?
- is a news article about **technology**, **politics**, or **sports** ?
- is a piece of text expressing **positive** emotions, or **negative** emotions?
![cat](http://i.imgur.com/bQG1uvQ.gif)
## Usage
```javascript
var classifier = NaiveBayes();
classifier
// teach it positive phrases
..learn(
['amazing', 'awesome', 'movie', 'Yeah', 'Oh', 'boy'],
'positive',
)
..learn(
['Sweet', 'this', 'is', 'incredibly', 'amazing', 'perfect', 'great'],
'positive',
)
// teach it a negative phrase
..learn(
['terrible', 'shitty', 'thing', 'Damn', 'Sucks'],
'negative',
);
// now ask it to categorize a document it has never seen before
classifier.categorize(['awesome', 'cool', 'amazing', 'Yay']);
// => 'positive'
classifier.probabilities(['awesome', 'cool', 'amazing', 'Yay']);
// => [{category: positive, value: -12.218495165528731}, {category: negative, value: -13.462782102101373}]
// serialize the classifier's state as a JSON string.
var stateJson = classifier.toJson()
// load the classifier back from its JSON representation.
var revivedClassifier = NaiveBayes.fromJson(stateJson)
```
## References
Naive-Bayes Classifier for node.js
[https://github.com/ttezel/bayes](https://github.com/ttezel/bayes)
[pull request] New method: .probabilities()
[https://github.com/ttezel/bayes/pull/7](https://github.com/ttezel/bayes/pull/7)
近期下载者:
相关文件:
收藏者: