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
Will the ball clear the crossbar of the goal post, which is 10 feer off the fround.
Allisa [31]

The problem gives you X, so replace X witht he given vaule and solve for y:


y = -0.1x^2 + 4X

X = 40

y = -0.1(40)^2 +4(40)

y = -0.1(1600) + 160

y = -160 + 160

y = 0


7 0
3 years ago
Please show work too I really need help
kumpel [21]

Answer:

i really  really like ya cut g

Step-by-step explanation:

3 0
3 years ago
Reasoning Kareem cannot decide which of two washing machines to buy. The selling price of each is $720. The first is marked down
Marina CMI [18]

Answer:

store one

Step-by-step explanation:

Store One:

$720(0.50)=$360

$720-$360=$360

Store Two:

$720(0.30)=$216

$720-$216=$504

$504(0.20)=$100.8

$504-$100.8=$403.2

5 0
3 years ago
Mark has a piece of wood 4 1/4 feet long. Tony has a piece of wood 1 2/4 feet long. How much wood do the boys have altogether. p
Alona [7]
They have 5 3/4 ft

4+1=5
1/4+2/4=3/4


but hey, its not the length of your wood that matters, its how you use it XD
8 0
4 years ago
I really need help with this ... I hope someone can help!
viva [34]

9514 1404 393

Answer:

  ∠B = 53°

  ∠C = 127°

  ∠D = 127°

Step-by-step explanation:

The trapezoid is isosceles, as indicated by the hash marks on sides AD and BC. This means it is symmetrical about the vertical center-line. Angles on the right will have the same measures as the symmetrical angles on the left.

So, you know immediately that ∠B = ∠A = 53°.

Because AB ║ DC, ∠A and ∠D are supplementary. That is, ...

  ∠D = ∠C = 180° -53°

  ∠D = ∠C = 127°

4 0
3 years ago
Other questions:
  • Please help I don’t understand
    9·1 answer
  • You have space in your garden for 60 small flowering bulbs. Crocus bulbs cost $0.25 each and daffodil bulbs cost $0.65 each. You
    13·1 answer
  • a triangle has side measuring 8 inches and 12 inches if x represents the length in inches o the third side which inequality give
    12·1 answer
  • Provide an exact evaluation of the expression: tan (-285°).
    11·2 answers
  • W<br> Given that m + 3n: m +9n<br> 2:5.<br> Write an equation in terms of m and n<br> m=
    8·1 answer
  • What is the correct answer?​
    13·1 answer
  • Pleas help!<br><br> WILL THANKS YOUR ACCONT and MARK BRAINLIEST
    12·1 answer
  • 5x + 3 &lt; -7 <br> you have to show work
    14·2 answers
  • One button is chosen at random from a bag of buttons.
    15·1 answer
  • How do I convert 1 5/6 into a decimal??????
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!