0
votes

I run a training set using Naive Bayes classifier using Weka. The resulted model is shown below. My question is:

a. Is it possible to incorporate the model into my java code?

b. If so, how can I do that?

c. If not, what should I do?

Thanks.

=== Classifier model (full training set) ===

Naive Bayes (simple)

Class A: P(C) = 0.42074928

Attribute mcv 'All'
1

Attribute alkphos 'All'
1

Attribute sgpt 'All'
1

Attribute sgot 'All'
1

Attribute gammagt '(-inf-20.5]' '(20.5-inf)'
0.54421769 0.45578231

Attribute drinks 'All'
1

Class B: P(C) = 0.57925072

Attribute mcv 'All'
1

Attribute alkphos 'All'
1

Attribute sgpt 'All'
1

Attribute sgot 'All'
1

Attribute gammagt '(-inf-20.5]' '(20.5-inf)'
0.30693069 0.69306931

Attribute drinks 'All'
1

Time taken to build model: 0 seconds

1

1 Answers

1
votes

It is possible to build your naive Bayes model in Java using Weka. Once built you can use this model to predict the outcome of test instances using Weka.

A good source to begin using Weka in your Java code is here, and a more advanced tool is the Weka API here.

Provided you are able to load your training instances (called "train" below) and testing instances (called "test" below), the naive Bayes model can be built and then used as follows:

    //build model
    NaiveBayes model=new NaiveBayes();
    model.buildClassifier(train);

    //use
    Evaluation eval_train = new Evaluation(test);
    eval_train.evaluateModel(model,test);