Using naive bayes model generated by the toolkit


#1

Hi,

I have some data. I am trying to train it using Naive Bayes classification provided by the MeTA toolkit. I trained it and I received all the relevant measures.

But now, I wish to apply it. That is, if I have an input, what should I do to get the output. I am unable to understand how that it to be done. Kindly help me out.

Thanks!


#2
// load the forward_index you used for training the model
auto config = cpptoml::parse_file("config.toml");
auto f_idx = index::make_index<index::forward_index>(*config);

// load your input document
corpus::document doc;
doc.content("<YOUR CONTENT HERE>");

// convert the document to a feature_vector by using the same 
// pipeline as your training data's index
auto vec = f_idx->tokenize(doc);

// classify using your model, which you can obtain either by
// training it and just keeping it around in memory, or by 
// loading it with classify::load_classifier(std::istream&).
auto label = model.classify(vec);

#3

Yeah. Works. Thanks a lot for your help.