Question: Use the matrix function to create the following confusion matrix: USING R > confusion.matrix Computed Accept Computed Reject Accept 540 460 Reject 23460 75540 (2

  1. Use the matrix function to create the following confusion matrix: USING R

> confusion.matrix

Computed Accept Computed Reject

Accept 540 460

Reject 23460 75540

  1. (2 Points) Show your code and the matrix that you created.
  1. (3 Points) Make confusionP (created in Script 3.5 below) a function in your global environment. Using the function, show the number correct, the number incorrect, and the accuracy for the above confusion matrix.

# Script 3.5 Computing Classification Accuracy # This function uses confusion matrix x to determine # model accuracy. confusionP <- function (x) # This function uses confusion matrix x to determine # model accuracy. {correct=0 wrong =0 y<- nrow(x) z<- ncol(x) for (i in 1:y) { for (j in 1:z) if(i==j) correct = correct + x[i,j] else wrong = wrong + x[i,j] } pc <-(round(correct/(correct + wrong)*100,2)) cat(" Correct=", correct," ") cat("Incorrect=", wrong," ")

cat("Accuracy =",pc,"%"," ") }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!