2 Basic Usage
This section provides details on the basic usage of the nbc4va package which includes bringing up the Graphic User Interface and running the Naive Bayes Classifier algorithm using file input and output.
2.1 User Interface
The simplest way to use the package is to open the Graphical User Interface (GUI) in your default web browser with nbc4vaGUI()
.
Once the GUI is loaded, follow the instructions to fit a NBC model to your training.csv
and to evaluate its performance with your testing.csv
data.
2.1.1 Example of GUI
If nbc4vaGUI()
is called sucessfully, the GUI shown in the image below should be available in your web browser.
2.1.2 Sample Code for GUI
Run the following code using nbc4vaGUI()
in a R console to open the GUI in your web browser:
library(nbc4va) # load the package
nbc4vaGUI() # open the GUI in your web browser
Close the GUI by pressing escape while you are in the R console.
2.1.3 References for GUI
See the Methods section for definitions of performance metrics and terms in the model results.
2.2 File Input and Output
The nbc4vaIO()
function can be called to fit a NBC model and save its results using the paths to your training
and testing
files in Comma Separated Values (CSV) format.
The saved results will in a selected directory with four CSV files detailing the performance of the model:
.._pred.csv
: a table of predictions, where the columns Prediction1..PredictionN are the cause of death predictions with Prediction1 being the most probable cause.._prob.csv
: a table of probabilities, where each column is a cause of death and each cell is the probability of a case being that cause.._causes.csv
: a table of metrics for each cause.._metrics.csv
: a table of summary metrics for the model- The .. represents the name of your
testing
file
2.2.1 Example of File Input and Output
The image below shows the input files on the left and the saved results on the right using the nbc4vaIO()
function (with the fileHeader
argument set to "nbc4va"
).
2.2.2 Sample Code for File Input and Output
Run the following code using nbc4vaIO()
in a R console to produce NBC model performance results with the training
and testing
files.
library(nbc4va)
# Find paths to your "trainFile" and "testFile"
<- file.choose() # select train file first
trainFile <- file.choose() # followed by test file after
testFile
# Run NBC model
# Dump results to same directory as "testFile"
# Set "known"" to indicate whether testing causes are known
nbc4vaIO(trainFile, testFile, known=TRUE)
2.2.3 References for File Input and Output
- See the Data section for
training
andtesting
file formats - See the Methods section for definitions of performance metrics and terms in the model results
For complete function specifications and usage of nbc4vaIO()
, run the code below in an R console:
library(nbc4va)
?nbc4vaIO