sk_bayes: SK Bayes These are supervised learning methods based on...

View source: R/sklearn.R

sk_bayesR Documentation

SK Bayes These are supervised learning methods based on applying Bayes’ theorem with strong (naive) feature independence assumptions.

Description

Usage

sk_bayes()

Value

python object

Examples

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

abresler/sklearn documentation built on July 27, 2023, 7:07 a.m.