1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
mote1985 [20]
3 years ago
7

Randomly split the messages into a training set D1 (80% of messages) and a testing set D2 (20% of messages). Calculate the testi

ng 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
Mathematics
1 answer:
Blizzard [7]3 years ago
3 0

Answer:

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

You might be interested in
Estimate then find the sum 63,824+29,452​
ASHA 777 [7]
90,000 becuase 63,824 is rounded down to 60,000 and 29,452 is rounded up to 30,000. 60,000+30,000 is 90,000
3 0
3 years ago
Draw a quick picture to show the number write how many tens and ones there are Edna has 82 stamps
ale4655 [162]
Here you go. A quick picture to demonstrate the problem. Hope this helps!! <span />

8 0
3 years ago
Find the inverse for each relation:<br> 1. {(1,-2), (2, 3),(3, -3),(4, 2)}
andrey2020 [161]

Answer:

the inverse for each relation:

1. {(1,-2), (2, 3),(3, -3),(4, 2)} is

<u>{</u><u>(</u><u>-</u><u>2</u><u>,</u><u>1</u><u>)</u><u>,</u><u>(</u><u>3</u><u>,</u><u>2</u><u>)</u><u>,</u><u>(</u><u>-</u><u>3</u><u>,</u><u>3</u><u>)</u><u>,</u><u>(</u><u>2</u><u>,</u><u>4</u><u>)</u><u>}</u><u>.</u>

3 0
3 years ago
a square with an area of 144 cm² is reduced by a factor of 1/3 how long are the new sides of the square?​
olga55 [171]

Answer:

4  cm

Step-by-step explanation:

The square root of 144 is 12 (12 x 12 = 144) so we know our sides of the square are 12 cm²

12 / 3 = 4

(\frac{12}{1} x \frac{1}{3})

The sides of the new square are 4 :)

Hope this helps and is correct, have a nice day! :D

3 0
3 years ago
If you help will make you brainlest
Bumek [7]

Answer:

see below

Step by step explanation

\because \: revenue = price \times demand \\   \therefore \: r(x) = x.d(x) \\ \therefore \: r(x) =x(200 - 2x)  \\\therefore \: r(x) = \boxed{200x - 2 {x}^{2}  }

5 0
2 years ago
Other questions:
  • Look at attachment for question
    14·1 answer
  • The median of 1,2,2,8,9,14
    15·2 answers
  • The worldwide market share for a web browser was 20.3​% in a recent month. Suppose that a sample of 120 random students at a cer
    14·1 answer
  • The distance from a point to a line
    10·1 answer
  • Solve the quadratic equation by completing the square: 6x²-11x-10=0 ​
    10·1 answer
  • THE CORRECT ANSWER WILL GET BRANLIEST
    7·1 answer
  • Three ratios equal to 8/10
    10·1 answer
  • (9t + 1) + 7(1 + 9t)<br><br> Complete the missing expressions!!
    9·1 answer
  • Matrices question need help
    6·1 answer
  • Which of the following shows 12 more than a number, written as an algebraic expression?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!