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
Please help ASAP!!!!!!
Schach [20]

Answer:

see explanation

Step-by-step explanation:

(f + g)(x) = f(x) + g(x), so

f(x) + g(x)

= x² + 5x + 6 + x + 3 ← collect like terms

= x² + 6x + 9

-------------------------------------------------

(f - g)(x) = (f(x) - g(x), so

f(x) - g(x)

= x² + 5x + 6 - (x + 3) ← distribute by - 1

= x² + 5x + 6 - x - 3 ← collect like terms

= x² + 4x + 3

---------------------------------------------------

(f • g)(x)

= f(x) × g(x)

= (x² + 5x + 6)(x + 3)

Each term in the second factor is multiplied by each term in the first factor, that is

x²(x + 3) + 5x(x + 3) + 6(x + 3)  ← distribute parenthesis

= x³ + 3x² + 5x² + 15x + 6x + 18 ← collect like terms

= x³ + 8x² + 21x + 18

---------------------------------------------------------------

(\frac{f}{g} )(x)

= \frac{f(x)}{g(x)}

= \frac{x^2+5x+6}{x+3} ← factor the numerator

= \frac{(x+2)(x+3)}{x+3} ← cancel common factor (x + 3) on numerator/ denominator

= x + 2

7 0
3 years ago
I WILL BE MARKING YOU BRAINLIST! You have to read the statement and see if it is true or false for the blue circle.
larisa86 [58]

Answer:

im pretty sure its false

Step-by-step explanation:

6 0
3 years ago
Nicole wants to buy a pair of jeans. The original cost of the jeans is $42.50 and he markup is 10 percent. How much will she hav
dangina [55]

Answer:

She'll have to pay $46.75

Step-by-step explanation:

42.50 divided by 10% is 425 which equals $4.25. 42.50 + 4.25 = 46.75

42.50 + 10% = 46.75. So therefore you can check your answer twice and it will be the same answer.

8 0
4 years ago
I need help im struggling​
Vladimir79 [104]

Answer:

62.80

Step-by-step explanation:

I hope this helped you out!!

7 0
3 years ago
Read 2 more answers
Which equations are true for x = –2 and x = 2? Select two options x2 – 4 = 0 x2 = –4 3x2 + 12 = 0 4x2 = 16 2(x – 2)2 = 0
Svetllana [295]

The equation x^{2} -4=0~~and~~4x^2=16 are true for  x = -2 and x = 2.

The given equations are given as:

x^2-4=0\\\\x^2=-4\\\\3x^2+12=0\\\\4x^2=16\\\\2(x-2)^2=0

We need to select two equations that are true for x = -2 and x = 2.

<h3>What are the solutions to an equation ?</h3>

The solutions of an equation are the values that satisfy the given equation or make the equation true when substituted for unknowns in the equations.

Example:

x - 2 = 2

Here the solution for x - 2 = 2 is 4 because x = 4 will make the equation true.

4 - 2 = 2

2 = 2

Let's find the solutions for each equation.

1.

x^2 - 4=0

x^{2} = 4

x = \sqrt{4} = ± 2

x = = 2 and x = -2

2.

x^2 =-4

x = \sqrt{-4}

x = \sqrt{-1 \times 4} = \sqrt{-1}\times\sqrt{4}

x = ± 2 \sqrt{-1}

x = 2i and x = -2i         where i = \sqrt{-1}

3.

3x^{2} + 12  = 0

x^{2} = -12 / 3 = -4

x = \sqrt{-1} \sqrt{4}

x = ± 2\sqrt{-1}

x = 2i and x = -2i

4.

4x^{2} = 16

x^{2} = 16 / 4

x^{2} = 4

x = \sqrt{4}

x = ±2

x = 2 and x = -2

5.

2(x-2)^2 = 0

(x-2)^2 = 0

x - 2 = 0

x = 2.

Thus the equation x^{2} -4=0~~and~~4x^2=16 have solutions x = -2 and x = 2.

Learn more about solutions of equations here:

brainly.com/question/14506845

#SPJ1

4 0
2 years ago
Other questions:
  • Leon evaluated the expression (–4a – 6) + a2 for a = 8. (-4(8) - 6) + 82 (-32-6) + 82 (-38) + 82 (-38) + 16 –19 + 16 –3 Analyze
    15·2 answers
  • Suppose k and l are fixed numbers. Since the following are lines with different slopes, the graphs of the two lines y=18x+k and
    8·1 answer
  • 12 to the third over 12 to the seventh (12^3/12^7)? the answers are 12^4, 1/12^4, 1/12^-4, or 12^10
    13·1 answer
  • What number is composite 2,11,9,5
    10·1 answer
  • Luis is buying cork to cover a bulletin board.The bulletin board is 1.1 meters long and 0.56m wide. If cork is $32 per meter squ
    9·1 answer
  • A school play cost $1,200 to produce. If tickets sold for $5 each, the profit, p p , made on the play by selling x x tickets is
    14·1 answer
  • Amy has saved $725 for a new guitar and lessons. Her guitar costs $475 and lessons are $25 per hour. Determine how many lessons
    7·1 answer
  • Find the equation of the line between the points (10, – 5) and ( - 2,0).
    15·1 answer
  • At the end of a snow storm, Riley saw there was a lot of snow on her front lawn. The temperature increased and the snow began to
    5·1 answer
  • a sphere is inscribed in a cube. the edge of the cube is 12 cm. what is the volume of the cube and sphere?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!