fnb.io: Save & Load Function for Fast Naive Bayes Models

Description Usage Arguments Value Examples

Description

Loads and saves fitted Naive Bayes models.

Usage

1
2
3
4
5
6
7
8
9
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
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")

fastNaiveBayes documentation built on May 4, 2020, 5:09 p.m.