sk_bayes | R Documentation |
sk_bayes()
python object
library(tidyverse)
library(sklearn)
library(caret)
bayes <- sk_bayes()
X <- iris %>% as_tibble %>% select_if(is.numeric)
target <- iris %>% pull(Species)
gnb <- bayes$GaussianNB()
model <- gnb$fit(X = as.matrix(X), y = target)
predictions <- model$predict(X = X)
result_table <- table(target, predictions)
confusionMatrix(result_table)
### Class probability
options(digits = 3, scipen = 9999)
df_prob <-
gnb$predict_proba(X = X) %>%
as_tibble() %>%
set_names(target %>% unique())
df_prob
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.