I am currently using GNaiveBayes along with GAutoFilter. When I use my model for a prediction:
model.predict(query_vector, predicted_label);
Then the predicted_label holds the predicted class (0 or 1). Instead, I would like to get the numerical values, such p(0)=0.45 and p(1)=0.55, because I would like to set the classification threshold to another value. (I assume it uses 0.5 as default).
Is this possible with the existing Waffles classes, or do I need to make a new subclass of GNaiveBayes?
Thanks
Pete
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The GNaiveBayes::predictDistribution method returns GPrediction objects. The GPrediction::asCategorical method returns categorical distributions. The, GCategoricalDistribution::likelihood method will tell you the likelihood of each category.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
// load the training data
GMatrix training_matrix;
training_matrix.loadArff("training.arff");
// Split into separate data and class matrices, as required by Waffles algos
// The "1" in the constructor means keep the last column as the label
GDataColSplitter splitter(training_matrix, 1);
GMatrix & features = splitter.features();
GMatrix & labels = splitter.labels();
// Create and train a model
GAutoFilter model(new GNaiveBayes());
model.train(features, labels);
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am currently using GNaiveBayes along with GAutoFilter. When I use my model for a prediction:
Then the predicted_label holds the predicted class (0 or 1). Instead, I would like to get the numerical values, such p(0)=0.45 and p(1)=0.55, because I would like to set the classification threshold to another value. (I assume it uses 0.5 as default).
Is this possible with the existing Waffles classes, or do I need to make a new subclass of GNaiveBayes?
Thanks
Pete
The GNaiveBayes::predictDistribution method returns GPrediction objects. The GPrediction::asCategorical method returns categorical distributions. The, GCategoricalDistribution::likelihood method will tell you the likelihood of each category.
Thanks Mike.
Here's a code snippet for anyone else who is trying to figure this out:
This assumes you've created your model like so: