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]
2 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]2 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
The average amount of time that students use computers at a university computer center is 36 minutes with a standard deviation o
frosja888 [35]

Answer:

2119 students use the computer for more than 40 minutes. This number is higher than the threshold estabilished of 2000, so yes, the computer center should purchase the new computers.

Step-by-step explanation:

Problems of normally distributed samples are solved using the z-score formula.

In a set with mean \mu and standard deviation \sigma, the zscore of a measure X is given by:

Z = \frac{X - \mu}{\sigma}

The Z-score measures how many standard deviations the measure is from the mean. After finding the Z-score, we look at the z-score table and find the p-value associated with this z-score. This p-value is the probability that the value of the measure is smaller than X, that is, the percentile of X. Subtracting 1 by the pvalue, we get the probability that the value of the measure is greater than X.

In this problem, we have that:

\mu = 36, \sigma = 5

The first step to solve this question is finding the proportion of students which use the computer more than 40 minutes, which is 1 subtracted by the pvalue of Z when X = 40. So

Z = \frac{X - \mu}{\sigma}

Z = \frac{40 - 36}{5}

Z = 0.8

Z = 0.8 has a pvalue of 0.7881.

1 - 0.7881 = 0.2119

So 21.19% of the students use the computer for longer than 40 minutes.

Out of 10000

0.2119*10000 = 2119

2119 students use the computer for more than 40 minutes. This number is higher than the threshold estabilished of 2000, so yes, the computer center should purchase the new computers.

8 0
3 years ago
A man shares his money between his sons, Cyrus and Peter in the ratio 4 : 9. If Cyrus' share is GH¢100, find the amount shared a
statuscvo [17]

Answer:

peter will get 225

6 0
2 years ago
Which number is IRRATIONAL ?? (if answered really fast, i will give brainiest plus 100 points for the CORRECT answer.
Delvig [45]

Answer:

C

btw Hannah is this one fine? sorry i couldn't remember which question was the chat and sorry i couldn't respond right away im not the person who is on late in the day

Step-by-step explanation:

3 0
3 years ago
Select the correct answer from each drop-down menu. Right triangle ABC is represented with the right angle at vertex B. Base BC
Svetradugi [14.3K]

By using trigonometric relations, we will see that:

AC = 15.6 in

AB = 8.4 in.

<h3>How to get the measures of the other two sides of the right triangle?</h3>

Here we have the right triangle where:

B = 90°

C = 40°

BC = 10 in.

Notice that is the adjacent cathetus to the angle C, then we can use the two relations:

  • sin(a) = (adjacent cathetus)/(hypotenuse).
  • tan(a) = (opposite cathetus)/(adjacent cathetus).

Where:

  • hypotenuse = AC
  • opposite cathetus = AB.

Then we will have:

sin(40°) = 10in/AC.

AC = 10in/sin(40°) = 15.6 in

tan(40°) = AB/10in

tan(40°)*10in = AB = 8.4 in.

So we can conclude that for the given right triangle we have:

AC = 15.6 in

AB = 8.4 in.

If you want to learn more about right triangles:

brainly.com/question/2217700

#SPJ1

6 0
1 year ago
The school that Stefan goes to is selling tickets to a choral performance. On the first day of ticket sales the school sold 3 se
aniked [119]
52 - 38 is 14 
since on the second they sold one more child ticket then the first day we know the extra money is the price of a child ticket 
so 14 is how much a child ticket is 
if 3 senior citizen tickets but 14$ = 38 
subtract 14 from38 = 24
and then 24/3 =senior ticket
child:14$
senior:8$
5 0
3 years ago
Other questions:
  • An elliptical cylinder is sliced by a plane, as shown in the figure. Among the four given two-dimensional shapes, shape
    8·2 answers
  • Pamela and her friend Nicole are each baking apple pies and tarts for a bake sale, using the same recipes. Pamela baked 5 apple
    12·1 answer
  • Complete the following equality. 11 ft = in.
    9·1 answer
  • Solve the equation 4x^3 + 4x^2-x-1 = 0 given that -1/2 is a zero of f(x) = 4x^3 + 4x^2-x-1.
    11·1 answer
  • I will make u a brainliest plz help me
    10·2 answers
  • Evaluate the 1/3 of 10.2​
    7·1 answer
  • The number of books in a library tends to increase by the same amount each year. Should
    14·1 answer
  • Factor the expression.<br> 2x + 8
    5·1 answer
  • Is 12:20 , 30:50 , 75:125 equivalent
    6·1 answer
  • Justity each step in solving the equation 4x = 7(x - 3) by writing a reason for each statement Answer Statement Reason 1. 4x7x3)
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!