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
Find the distance between the two points. (1, 2), (7, 6) The distance between the two points is __ units
katrin [286]

Answer:

7.2

Step-by-step explanation:

distance between the two points. (1, 2), (7, 6) = √(x-x')²+(y-y')²

d = √(7-1)²+(6-2)² = √52 = 7.2

8 0
3 years ago
what is the slope of the picture (if this is super easy, the reason I asked this question is that my brain is working horrible t
Sedaia [141]

Answer:3/2 or 1.5

Step-by-step explanation:

(9-6)/(3-1)=

3/2

7 0
3 years ago
Which ordered pair is a solution to the system?
andreyandreev [35.5K]

Answer:

A.

Step-by-step explanation:

5>4

6>2

5 is greater than 4, 6 is greater than 2

8 0
3 years ago
Find the other endpoint of the line segment with the given endpoint -5, 2 and midpoint 2, -5
DIA [1.3K]

Answer:

( 9, -12 )

Step-by-step explanation:

Mario's Math Tutoring

you have the midpoint

2, -5

use the midpoint formula

(x1+x2)/2 , (y1+y2)/2

to get the endpoint

x :

(-5+x2)/2 = 2

(-5+x2) = 4

-5+x2 = 4

x2 = 9

y:

(2+y2)/2 = -5

(2+y2) = -10

2+y2 = -10

y2 = -12

Thank you Mario!

5 0
2 years ago
Which set of numbers forms a Pythagorean triple?
egoroff_w [7]

Answer:

3, 4, 5

Step-by-step explanation:

3 ^2 = 9

4 ^2 = 16

5 ^2 = 25

9 + 16 = 25

6 0
3 years ago
Other questions:
  • Spending $14, $9, and then $31 will result in balance of ___ *
    10·2 answers
  • WILL GIVE BRAINLIEST!
    15·2 answers
  • what kind of polygon is included in both a net of a triangular prism and a net of a rectangular prism
    8·2 answers
  • The average amount of rent paid for apartments in Middle River is $981 per month, which is 10% less than it was last winter.
    14·2 answers
  • Write an equation like y=mx+b to describe the graph
    13·2 answers
  • Liliana bought a book for $13. She is selling the book for $24. What is the percent markup on the price of the book? Round to th
    9·1 answer
  • Could someone please help me with these?
    15·2 answers
  • What is the least common multiple of 7 and 10?
    11·1 answer
  • 6x +16 &gt;=51 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
    5·1 answer
  • III Convert the following: -<br> a) 5 Km 20 m into m<br> b) 7 m 13 cm into m<br>​
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!