Last active
January 15, 2019 09:55
-
-
Save ridwanbejo/6a3af185ab1946732d4ddd185cf1a3a2 to your computer and use it in GitHub Desktop.
naive bayes classification non cross validation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(e1071) | |
library(gmodels) | |
# 1. Load dataset from CSV | |
bank_csv <- read.csv("./Downloads/bank-additional/bank-additional-full.csv", header=TRUE, sep=";") | |
bank_df <- as.data.frame(bank_csv[1:32951,]) | |
summary(bank_df) | |
# 2. Do the preprocessing | |
# 2.1. todo | |
# 2.2. todo | |
# 2.3. todo | |
# 2.4. todo | |
# 3. Train the model | |
model <- naiveBayes(y ~ ., data=bank_df, laplace=1) | |
# 4. Test the model | |
term_deposit_test <- predict(model, bank_csv[32952:41188,1:20]) | |
# 5. Evaluate the model | |
CrossTable(term_deposit_test, bank_csv[32952:41188,21], prop.chisq = FALSE, prop.t = FALSE, dnn = c('predicted', 'actual')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment