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
What is 3/4 times 8/3 i need a correct
bija089 [108]
2 would be the correct answer:)

6 0
3 years ago
Read 2 more answers
Write the equation of the line that passes through the points (3,5) and (-1,1). Put
dangina [55]

Given:

A line passes through the two points (3,5) and (-1,1).

To find:

The equation of the line in fully reduced point-slope form.

Solution:

If a line passes through two points, then the point slope form of the line is

y-y_1=\dfrac{y_2-y_1}{x_2-x_1}(x-x_1)

The line passes through the two points (3,5) and (-1,1). So, the point slope form of the line is

y-5=\dfrac{1-5}{-1-3}(x-3)

y-5=\dfrac{-4}{-4}(x-3)

y-5=1(x-3)

Therefore, the  point slope form of the line in fully reduced form is y-5=1(x-3), here 1 is the slope of the line.

6 0
3 years ago
I need help asap , im doing this thing and I cant do it im confused
aksik [14]

Answer:

they will be the same at 11 months

Step-by-step explanation:

the equations for this are

y = 40+55x

and

y = 165+30x

where x is the number of months

if you plug this into your graphic calc you see they are equal at 11 therefore, 11 months

6 0
3 years ago
The student council at Spend too much High School is planning a school dance. The table below shows the budget for the dance.
Pie
The dance would /cost/ the school 50 dollars, making the profit -50. The dance tickets make 300, and the DJ takes away 250, making a 50 profit. However, the decorations cost 100, taking away that from 50, making -50.
4 0
3 years ago
I need help it's geometry
nekit [7.7K]

Step-by-step explanation:

\sin(45)  =  \frac{x}{5}  \\   \frac{1}{ \sqrt{2} } =  \frac{x}{5}    \\ x =  \frac{5}{ \sqrt{2} }  = 3.535

\sin(45)  =  \frac{y}{5}  \\ y =  \frac{5}{ \sqrt{2} }  = 3.535

3 0
3 years ago
Read 2 more answers
Other questions:
  • Answer the following 4 questions CORRECTLY I will know if this is wrong. I WILL REPORT ANY INCORRECT ANSWERS!
    9·2 answers
  • 3.14<br><img src="https://tex.z-dn.net/?f=3.14%20%5Ctimes%208" id="TexFormula1" title="3.14 \times 8" alt="3.14 \times 8" align=
    15·2 answers
  • What is the surface area of a cylinder with base radius 3and height 8
    8·2 answers
  • Which property justifies this r(s + t) = rs + rt<br> statement
    10·2 answers
  • Explain the translation shown in the picture below
    15·1 answer
  • Answer the questions below about the quadratic function
    7·1 answer
  • Salma, joe, and alan sent a total of 106 text messages during the weekend, salma sent 9 fewer messages than alan. Joe sent 3 tim
    10·1 answer
  • Can you please help me. If you help me i will give you brainliest ( question 6)
    15·1 answer
  • The opposite sides of a parallelogram have measures (2x+10) cin and (x+15)
    14·1 answer
  • The melting point of nitrogen is -210 °C. The melting point of magnesium is 650 °C.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!