Learn R Programming

nbc4va (version 1.2)

plot.nbc: Bar plot of top predicted causes from a NBC model

Description

Plots the results from a nbc object as a barplot for a number of causes based on predicted Cause Specific Mortality Fraction (CSMF).

Usage

# S3 method for nbc
plot(
  x,
  top.plot = length(x$causes.pred),
  min.csmf = 0,
  csmfa.obs = NULL,
  footnote = TRUE,
  footnote.color = "gray48",
  footnote.size = 0.7,
  main = paste("Naive Bayes Classifier: Top ", top.plot, " Causes by Predicted CSMF",
    sep = ""),
  xlab = "Predicted CSMF",
  col = "dimgray",
  horiz = TRUE,
  border = NA,
  las = 1,
  ...
)

Arguments

x

A nbc object.

top.plot

A number that produces top k causes depending on a Cause Specific Mortality Fraction (CSMF) measure.

min.csmf

A number that represents the minimum CSMF measure for a cause to be included in the plot.

csmfa.obs

A character vector of the true causes for calculating the CSMF accuracy.

footnote

A boolean indicating whether to include a footnote containing details about the nbc or not.

footnote.color

A character specifying the color of the footnote text.

footnote.size

A numeric value specifying the size of the footnote text.

main

A character value of the title to display.

xlab

A character value of the x axis title.

col

A character value of the color to use for the plot.

horiz

Set to TRUE to draw bars horizontally and FALSE to draw bars vertically.

border

A character value of the colors to use for the bar borders. Set to NA to disable.

las

An integer value to determine if labels should be parallel or perpendicular to axis.

...

Additional arguments to be passed to barplot.

Value

Generates a bar plot the top predicted causes from the NBC model

Details

See Methods documentation for details on CSMF and CSMF accuracy.

See Also

barplot

Other main functions: nbc(), print.nbc_summary(), summary.nbc()

Examples

Run this code
# NOT RUN {
library(nbc4va)
data(nbc4vaData)

# Run naive bayes classifier on random train and test data
train <- nbc4vaData[1:50, ]
test <- nbc4vaData[51:100, ]
results <- nbc(train, test)

# Plot the top 3 causes by CSMF
plot(results, top.plot=3)

# }

Run the code above in your browser using DataLab