fnb.save {fastNaiveBayes} | R Documentation |
Save & Load Function for Fast Naive Bayes Models
Description
Loads and saves fitted Naive Bayes models.
Usage
fnb.save(model, filename, overwrite = FALSE)
## Default S3 method:
fnb.save(model, filename, overwrite = FALSE)
fnb.load(filename)
## Default S3 method:
fnb.load(filename)
Arguments
model |
the fitted Naive Bayes model to save. |
filename |
the file name to use to save or load the model. |
overwrite |
Whether to allow overwriting of previously saved models. |
Value
fnb.save returns the filename that was used, and fnb.load returns the saved object.
Examples
rm(list = ls())
library(fastNaiveBayes)
cars <- mtcars
y <- as.factor(ifelse(cars$mpg > 25, "High", "Low"))
x <- cars[,2:ncol(cars)]
mod <- fastNaiveBayes(x, y, laplace = 1)
fnb.save(mod, "fastNaiveBayesModel")
mod2 <- fnb.load("fastNaiveBayesModel")
identical(mod, mod2)
file.remove("fastNaiveBayesModel")
[Package fastNaiveBayes version 2.2.1 Index]