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
2. The next Saturday, the two friends leave at the same time a ain, and Kiran jogs twice
gladu [14]

Answer:

the end by the finish line

5 0
2 years ago
PLEASE help and explain the steps that you used
ddd [48]
I hope this helps you




5 0
4 years ago
I need the answer plsss
ss7ja [257]

Answer:

Its H

There should be one dot on 4, 2 dots on 2, 3 dots on 1, 3 dots on 0,  1 dot on 7, 1 dot on 3

Step-by-step explanation:

brainly plz!

7 0
3 years ago
Annie is filling flower pots with soil. Each flower pot is shaped like a cylinder. Just like the one here below. The radius is 2
Anna [14]

Answer:

  • None

Step-by-step explanation:

<u>Given:</u>

  • Radius r = 2 in =  2*2.54 cm = 5.08 cm
  • Height h = 6 in = 6*2.54 cm = 15.24 cm
  • Volume of soil V = 200 cm³

<u>Find the volume of one pot:</u>

  • V = πr²h
  • V = 3.14*5.08²*15.24 = 1234.92 cm³

From the number above we see the volume of each pot is greater than the volume of soil Ann has, so she can't fill any.

The answer is zero

<em>Note. If the volume unit of soil was in³ the answer would be different</em>

5 0
3 years ago
When you put the answer put it like this
Bas_tet [7]
Answer 1: -1+6n
Answer 2: 49+35t
Answer 3: -42+6w
Answer 4: -16-4q
Answer 5: -54-9k
Answer 6: -12g-8
4 0
3 years ago
Other questions:
  • Which of the following statements is TRUE?
    6·1 answer
  • Write the following number 45.08 in word form
    13·1 answer
  • The product of twice a number and six is the same as the difference of eleven times the number and 6/5 . Find the number
    8·1 answer
  • What is 133 1/3% as a frcation?
    13·1 answer
  • Ten less than double a number is the same as seven times the number. Find the number
    9·1 answer
  • Claim: The mean pulse rate (in beats per minute, or bpm) of adult males is equal to 69 bpm. For the random sample of 153 adult m
    7·1 answer
  • One skeleton in a museum has 189 bones.another skeleton has 232 bones. How many bones are in the two skeleton?
    7·1 answer
  • A coin placed below a rectangular glass prism of thickness 7.5cm and refractive index 1.5 is viewed vertically above the glass.
    13·1 answer
  • A line passes through the point (-4, -6) and has a slop of 5. Write an equation for this line.
    14·1 answer
  • X^4-6x-7-8y-y^2 help me to solve this question​
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!