naive_bayes 0.0.1

  • README.md
  • Installing
  • Versions
  • 38

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's bayes.js and @pwlmaciejewski's pull request.

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

Usage #

var classifier = NaiveBayes();

// teach it positive phrases

classifier.learn(['amazing', 'awesome', 'movie', 'Yeah', 'Oh', 'boy'], 'positive');
classifier.learn(['Sweet', 'this', 'is', 'incredibly', 'amazing', 'perfect', 'great'], 'positive');

// teach it a negative phrase

classifier.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

[pull request] New method: .probabilities()

https://github.com/ttezel/bayes/pull/7

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  naive_bayes: ^0.0.1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:naive_bayes/naive_bayes.dart';
  
Version Uploaded Documentation Archive
0.0.2 Jan 5, 2019 Go to the documentation of naive_bayes 0.0.2 Download naive_bayes 0.0.2 archive
0.0.1 Jan 5, 2019 Go to the documentation of naive_bayes 0.0.1 Download naive_bayes 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
43
Overall:
Weighted score of the above. [more]
38
Learn more about scoring.

We analyzed this package on May 8, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.3.0
  • pana: 0.12.15

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:naive_bayes/naive_bayes.dart.

Health issues and suggestions

Document public APIs. (-1 points)

11 out of 11 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Maintenance issues and suggestions

Provide a file named CHANGELOG.md. (-20 points)

Changelog entries help developers follow the progress of your package. See the example generated by stagehand.

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Homepage URL is insecure. (-5 points)

Update the homepage field and use a secure (https) URL.

Update README.md. (-2 points)

1 image link is insecure (e.g. http://i.imgur.com/bQG1uvQ.gif), use https URLs instead.

Maintain an example.

None of the files in the package's example/ directory matches known example patterns.

Common filename patterns include main.dart, example.dart, and naive_bayes.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0