# rxNaiveBayes: Parallel External Memory Algorithm for Naive Bayes Classifiers

## Description

Fit Naive Bayes Classifiers on an .xdf file or data frame for small or large data using parallel external memory algorithm.

## Usage

``````  rxNaiveBayes(formula, data, smoothingFactor = 0,   ...  )

``````

## Arguments

### `formula`

formula as described in rxFormula.

### `data`

either a data source object, a character string specifying a .xdf file, or a data frame object.

### `smoothingFactor`

a positive smoothing factor to account for cases not present in the training data. It avoids modeling issues by preventing zero conditional probability estimates.

### ` ...`

additional arguments to be passed directly to rxSummary such as `byTerm`, `rowSelection`, `pweights`, `fweights`, `transforms`, `transformObjects`, `transformFunc`, `transformVars`, `transformPackages`, `transformEnvir`, `useSparseCube`, `removeZeroCounts`, `blocksPerRead`, `reportProgress`, `verbose`, `xdfCompressionLevel`.

## Value

an `"rxNaiveBayes"` object containing the following components:

• `apriori` - a vector of prior class probabilities for the dependent variable.

• `tables` - a list of tables, one for each predictor variable.

• For a categorical variable, the table contains the conditional probabilities of the variable given the target class.
• For a numeric variable, the table contains the mean and standard deviation of the variable given the target class.
• `levels` - the levels of the dependent variable.

• `call` - the matched call.

## Author(s)

Microsoft Corporation `Microsoft Technical Support`

Naive Bayes classifier `https://en.wikipedia.org/wiki/Naive_Bayes_classifier` .

## Examples

``````
# multi-class classification with an .xdf file
{"ft_lang_label":"__label__en","ft_lang_prob":0.54491556,"math_prob":0.6044945,"size":1914,"snap":"2022-40-2023-06","text_gpt3_token_len":430,"char_repetition_ratio":0.121465966,"word_repetition_ratio":0.034042552,"special_character_ratio":0.19017763,"punctuation_ratio":0.20504732,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9903954,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-01-28T22:46:53Z\",\"WARC-Record-ID\":\"<urn:uuid:368e7a65-a9df-4dd2-8971-4f566812d846>\",\"Content-Length\":\"40805\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:8cc88f7e-a8ad-4fcb-8f70-1e641666f041>\",\"WARC-Concurrent-To\":\"<urn:uuid:55fb2f39-0ab1-4700-b0ef-3b5cccbf2e7d>\",\"WARC-IP-Address\":\"104.72.117.68\",\"WARC-Target-URI\":\"https://learn.microsoft.com/pt-br/machine-learning-server/r-reference/revoscaler/rxnaivebayes\",\"WARC-Payload-Digest\":\"sha1:MXVIZQJCJJ6JFBXFCUDJGYLQV24K366S\",\"WARC-Block-Digest\":\"sha1:E4UAKKQQ626IQEBJ4FYKNTBH7KGVWRWO\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-06/CC-MAIN-2023-06_segments_1674764499695.59_warc_CC-MAIN-20230128220716-20230129010716-00612.warc.gz\"}"}