Download the PHP package assisted-mindfulness/naive-bayes without Composer
On this page you can find all versions of the php package assisted-mindfulness/naive-bayes. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download assisted-mindfulness/naive-bayes
More information about assisted-mindfulness/naive-bayes
Files in assisted-mindfulness/naive-bayes
Package naive-bayes
Short Description Naive Bayes classifier algorithm
License MIT
Informations about the package naive-bayes
Naive Bayes
Naive Bayes works by looking at a training set and making a guess based on that set. It uses simple statistics and a bit of math to calculate the result.
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?
Installation
You may install Naive Bayes into your project using the Composer package manager:
Learning
Before the algorithm can do anything, it requires a training set with historical information. To teach your classifier which category the text belongs to, call the learn
method:
Guessing
After you have trained the classifier, you can use the prediction of which category the transmitted text belongs to, for example:
In order for you to enter more similar information, you can use:
Uneven
When the training set contains unbalanced data not intentionally but due to insufficient data, you can enable an 'uneven' mode that equalizes the probability calculation for document types.
Tokenizer
The algorithm utilizes a tokenizer to segment the text into words. By default, it splits the text by spaces and includes words with a length of more than 3 symbols. You can also define your custom tokenizer using the following example:
Wrapping up
There you have it! Even with a very small training set the algorithm can still return some decent results. For example, Naive Bayes has been proven to give decent results in sentiment analyses.
Moreover, Naive Bayes can be applied to more than just text. If you have other ways of calculating the probabilities of your metrics you can also plug those in and it will just as good.
License
The MIT License (MIT). Please see License File for more information.
All versions of naive-bayes with dependencies
illuminate/support Version ^9.0|^10.0|^11.0
brick/math Version ^0.9.3|^0.11|^0.12