Sakib Sami' Blog


Newbie programmer, Java fan, Rosogolla lover, Mom's little kid.


ML : Nur & His Magic Box

First time writing on Machine learning. In this post will discuss about text classification. We will use Naive Bayes Classifier for classification.

Lets start,

Ok, You may want to know what is classifier ?
Well, classifier classifies training data based on implemented algorithm as we are using Naive Bayes Classifier algorithm which is based on Bayes theorem. Naive Bayes Classifier works based on phrase frequency and its Supervised learning.

Lets assume Nur started using email and his relatives, teachers, friends are contacting via it. As well as he is using this email id in different social networks. As he is getting lots of email now, he want to categorize it so he can easily check emails from relatives, teachers, friends and others.

Nur has a MagicBox which is able to identify certain things based on preset data. So nur decides to take the help of magic box. So he started setting few key sentence and word based on which magic box will categorize emails.
Key sentence and words are like,
[Text] => [Label]

your aunty => [relative]
dear friend => [friend]
from Jhalokathi = [relative]
your cousin => [relative]
Dear subscriber => [social]
new post => [social]
new homework => [teacher]
is weekend => [teacher]
class teacher [teacher]

In machine learning this are called training data.

Now assume Nur got two email, Those are,

Hello nur, I am your class teacher Jessica. Tomorrow is weekend. So there is no homework. Enjoy the weekend.

And

Hello nur, I am Rupa your cousin.

Now lets check email category using Magic Box.

Ok, Nur got results from Magic Box and its correct.

Nurs Magic Box uses Naive Bayes Classifier algorithm to categorize data.
In supervised machine learning result accuracy depends on training data.

Used implementation of Naive Bayes Classifier : https://github.com/ptnplanet/Java-Naive-Bayes-Classifier

Example :

val bayesClassifier = BayesClassifier<String, String>()

// Learning
val tokenizeSampleText = "Sample Sentence".split(" ")  
val sampleLabel = "SampleLabel"  
bayesClassifier.learn(sampleLabel, tokenizeSampleText)

// Classify
val result = bayesClassifier.classify("QueryText".split(" "))  
println("Category : ${result.category}, Probability : ${result.probability}")  

Magic Box source code :
https://github.com/s4kibs4mi/machine-learning-garage

How To : EMQ plugin development

EMQ is a MQTT broker written in Erlang. The broker is opensource and licensed under Apache 2. EMQ br…

emqttd, mqtt, emq, erlang, plugin development, plugin, broker, mqtt broker

C/C++ Pointer

Todays blog post is on C/C++ pointer. Pointer allows you to access memory address directly. Pointer…

c, c++, pointer, memory, programming