mlpack
Classes | Functions
nbc_main.cpp File Reference
#include <mlpack/prereqs.hpp>
#include <mlpack/core/util/io.hpp>
#include <mlpack/core/data/normalize_labels.hpp>
#include <mlpack/core/util/mlpack_main.hpp>
#include "naive_bayes_classifier.hpp"
Include dependency graph for nbc_main.cpp:
This graph shows which files directly or indirectly include this file:

Classes

struct  NBCModel
 

Functions

 BINDING_NAME ("Parametric Naive Bayes Classifier")
 
 BINDING_SHORT_DESC ("An implementation of the Naive Bayes Classifier, used for classification. " "Given labeled data, an NBC model can be trained and saved, or, a " "pre-trained model can be used for classification.")
 
 BINDING_LONG_DESC ("This program trains the Naive Bayes classifier on the given labeled " "training set, or loads a model from the given model file, and then may use" " that trained model to classify the points in a given test set." "\" "The training set is specified with the "+PRINT_PARAM_STRING("training")+" parameter. Labels may be either the " "last row of the training set, or alternately the "+PRINT_PARAM_STRING("labels")+" parameter may be specified to pass a " "separate matrix of labels." "\" "If training is not desired, a pre-existing model may be loaded with the "+PRINT_PARAM_STRING("input_model")+" parameter." "\" "\" "The "+PRINT_PARAM_STRING("incremental_variance")+" parameter can be " "used to force the training to use an incremental algorithm for calculating" " variance. This is slower, but can help avoid loss of precision in some " "cases." "\" "If classifying a test set is desired, the test set may be specified with " "the "+PRINT_PARAM_STRING("test")+" parameter, and the classifications" " may be saved with the "+PRINT_PARAM_STRING("predictions")+"predictions" " parameter. If saving the trained model is desired, this may be " "done with the "+PRINT_PARAM_STRING("output_model")+" output " "parameter." "\" "Note: the "+PRINT_PARAM_STRING("output")+" and "+PRINT_PARAM_STRING("output_probs")+" parameters are deprecated and will " "be removed in mlpack 4.0.0. Use "+PRINT_PARAM_STRING("predictions")+" and "+PRINT_PARAM_STRING("probabilities")+" instead.")
 
 BINDING_EXAMPLE ("For example, to train a Naive Bayes classifier on the dataset "+PRINT_DATASET("data")+" with labels "+PRINT_DATASET("labels")+" " "and save the model to "+PRINT_MODEL("nbc_model")+", the following " "command may be used:" "\"+PRINT_CALL("nbc", "training", "data", "labels", "labels", "output_model", "nbc_model")+"\" "Then, to use "+PRINT_MODEL("nbc_model")+" to predict the classes of " "the dataset "+PRINT_DATASET("test_set")+" and save the predicted " "classes to "+PRINT_DATASET("predictions")+", the following command " "may be used:" "\"+PRINT_CALL("nbc", "input_model", "nbc_model", "test", "test_set", "output", "predictions"))
 
 BINDING_SEE_ALSO ("@softmax_regression", "#softmax_regression")
 
 BINDING_SEE_ALSO ("@random_forest", "#random_forest")
 
 BINDING_SEE_ALSO ("Naive Bayes classifier on Wikipedia", "https://en.wikipedia.org/wiki/Naive_Bayes_classifier")
 
 BINDING_SEE_ALSO ("mlpack::naive_bayes::NaiveBayesClassifier C++ class " "documentation", "@doxygen/classmlpack_1_1naive__bayes_1_1" "NaiveBayesClassifier.html")
 
 PARAM_MODEL_IN (NBCModel, "input_model", "Input Naive Bayes " "model.", "m")
 
 PARAM_MODEL_OUT (NBCModel, "output_model", "File to save trained " "Naive Bayes model to.", "M")
 
 PARAM_MATRIX_IN ("training", "A matrix containing the training set.", "t")
 
 PARAM_UROW_IN ("labels", "A file containing labels for the training set.", "l")
 
 PARAM_FLAG ("incremental_variance", "The variance of each class will be " "calculated incrementally.", "I")
 
 PARAM_MATRIX_IN ("test", "A matrix containing the test set.", "T")
 
 PARAM_UROW_OUT ("output", "The matrix in which the predicted labels for the" " test set will be written (deprecated).", "o")
 
 PARAM_UROW_OUT ("predictions", "The matrix in which the predicted labels for the" " test set will be written.", "a")
 
 PARAM_MATRIX_OUT ("output_probs", "The matrix in which the predicted probability" " of labels for the test set will be written (deprecated).", "")
 
 PARAM_MATRIX_OUT ("probabilities", "The matrix in which the predicted" " probability of labels for the test set will be written.", "p")
 

Detailed Description

Author
Parikshit Ram (pram@.nosp@m.cc.g.nosp@m.atech.nosp@m..edu)

This program runs the Simple Naive Bayes Classifier.

This classifier does parametric naive bayes classification assuming that the features are sampled from a Gaussian distribution.

mlpack is free software; you may redistribute it and/or modify it under the terms of the 3-clause BSD license. You should have received a copy of the 3-clause BSD license along with mlpack. If not, see http://www.opensource.org/licenses/BSD-3-Clause for more information.