![Chan592](/avatars/11100.jpg)
Chan592
11.10.2019 •
Mathematics
Randomly split the messages into a training set d1 (80% of messages) and a testing set d2 (20% of messages). calculate the testing accuracy, confusion matrix, precision, recall, and f-score of the na¨ıve bayes classifier in determining whether a message is spam or ham. submit your source code. note: let’s assume that spam is the positive class
Solved
Show answers
More tips
- F Food and Cooking Discovering the Mysterious Fruit of Feijoa...
- B Business and Finance How to Open an Online Store? A Detailed Guide for Beginners...
- W Work and Career How to Write a Resume That Catches the Employer s Attention?...
- C Computers and Internet Е-head: How it Simplifies Life for Users?...
- F Family and Home How to Choose the Best Diapers for Your Baby?...
- F Family and Home Parquet or laminate, which is better?...
- L Leisure and Entertainment How to Properly Wind Fishing Line onto a Reel?...
- L Leisure and Entertainment How to Make a Paper Boat in Simple Steps...
- T Travel and tourism Maldives Adventures: What is the Best Season to Visit the Luxurious Beaches?...
- H Health and Medicine Kinesiology: What is it and How Does it Work?...
Answers on questions: Mathematics
- M Mathematics Three brothers share one video game system at their home. in total, they are allowed to play for one half hour each day. if each brother play an equal amount of time, which shows...
- M Mathematics What is a good estimate for 684+ 2317.i need it today answer....
- M Mathematics Is every real number also a complex number?...
- M Mathematics Amachinist creates a washer by drilling a hole through the center of a circular piece of metal . if the piece of metal has a radius of x+10 and the hole has a radius of x+6, what...
- M Mathematics plz asap find the value of m...
- M Mathematics Need ! do you feel like it is easier to read a ruler in inches or centimeters? why do you feel that way? (consider which one may lead to more errors.)...
- M Mathematics Samantha purchased an automobile for 4,200. her state charged 4% tax for the car, $47 for the license plate, and $35 for the state safety and emission inspection. how much does samantha...
- M Mathematics Negative 20 over 23 divided by x over 4...
- M Mathematics Factor completely. p^2+7p+10 enter your answer in the box. factor completely. x^2−12x+35 enter your answer in the box. factor completely. w^2+2w−24 enter your answer in the box....
- M Mathematics Plz amswer fully! need done asap...
Ответ:
In the step-by-step
Step-by-step explanation:
This is the code i created using the R software and the packages "caret" and "e0171".
The script was supposed to work in all general cases.
library(caret)
library(e1071)
# Categorical vector
spam <- c("spam","not_spam")
spam_vec <- sample(spam,60, replace = T)
# Supposing two independent variables so that the kappa will be close to 0.
x1 <- rnorm(60)
x2 <- rnorm(60)
# Creating the dataset
data1 <- cbind(spam_vec,x1,x2)
data1 <- as.data.frame(data1)
names(data1) <- make.names(c("spamvec","x","y"))
# Creating the partition
index <- createDataPartition(data1$spamvec,
p=0.8, list=FALSE)
training_data <- data1[index,]
testing_data <- data1[-index,]
fitControl <- trainControl(method = "cv",
number = 5,
savePred = TRUE,
classProb = TRUE)
tune.grid <- expand.grid(C = seq(0, 10, .1))
# Scaling the predictors
preProcess_cs <- preProcess(training_data[, -1],
method = c("center", "scale"))
spam_training_cs <- predict(preProcess_cs, training_data)
spam_testing_cs <- predict(preProcess_cs, testing_data)
# Training a Naive Bayes to predict binary outcome
Naive_Bayes_Model=naiveBayes(spamvec ~.,
data=spam_training_cs,
tuneGrid = tune.grid,
trControl = fitControl)
# Confusion matrix
prediction <- predict(Naive_Bayes_Model, spam_testing_cs)
confusionMatrix(prediction, spam_testing_cs$spamvec, positive = "spam")
confM <- confusionMatrix(prediction, spam_testing_cs$spamvec, positive = "spam")
accuracy <- confM$overall[1]
accuracy
Ответ:
x= 12sorry if its wrong