AUC for 3-Class prediction in R

0 votes

I am building a multinomial logistic regression on top of the iris datas-set, to segregate it into 3 classes.

I'm using the mulitnom() function from the nnet package:

library(nnet)
mod1 = multinom(Species~., data = iris, trace = F)

After building the model, i am predicting the results on top of the iris data-set:

predict(mod1,iris)->result1
table(iris$Species,result1)

This only gives me a confusion matrix, but i want to find the AUC for these three classes, how can i do that?

Apr 4, 2018 in Data Analytics by BHARANI
• 410 points
144 views

1 answer to this question.

0 votes
  • Use type='probs' inside predict() function, so that you get the probabilities.
result1 = predict(model, data = iris, type='probs')
  • Then you can use the auc-multcap method from the handtill2001 package:

library(HandTill2001)
auc(multcap(
  response = iris$Species,
  predicted = as.matrix(result1)
))

This gives you an AUC value of  0.9990667

answered Apr 4, 2018 by Bharani
• 4,550 points

Related Questions In Data Analytics

0 votes
1 answer

What are the options for deploying models in production with R?

Well, I could say that the answer ...READ MORE

answered Apr 12, 2018 in Data Analytics by DataKing99
• 8,130 points
307 views
0 votes
2 answers

How to use group by for multiple columns in dplyr, using string vector input in R?

data = data.frame(   zzz11def = sample(LETTERS[1:3], 100, replace=TRUE),   zbc123qws1 ...READ MORE

answered Aug 5 in Data Analytics by anonymous
3,645 views
0 votes
1 answer

How to find out the sum/mean for multiple variables per group in R?

You can use the reshape2 package for ...READ MORE

answered Apr 12, 2018 in Data Analytics by DataKing99
• 8,130 points
442 views
0 votes
1 answer

Finding frequency of observations in R

You can use the "dplyr" package to ...READ MORE

answered Mar 26, 2018 in Data Analytics by Bharani
• 4,550 points
203 views
0 votes
1 answer

Left Join and Right Join using "dplyr"

The below is the code to perform ...READ MORE

answered Mar 26, 2018 in Data Analytics by Bharani
• 4,550 points
126 views
0 votes
1 answer

Plotting multiple graphs on the same page in R

If you want to plot 4 graphs ...READ MORE

answered Mar 27, 2018 in Data Analytics by Bharani
• 4,550 points
63 views
+1 vote
2 answers

Custom Function to replace missing values in a vector with the mean of values

Try this. lapply(a,function(x){ifelse(is.na(x),mean(a,na.rm = TRUE) ...READ MORE

answered Aug 14 in Data Analytics by anonymous
101 views
0 votes
2 answers

Installing MXNet for R in Windows System

You can install it for python in ...READ MORE

answered Dec 3, 2018 in Data Analytics by Kalgi
• 42,540 points
415 views
0 votes
2 answers

Transforming a key/value string into distinct rows in R

We would start off by loading the ...READ MORE

answered Mar 26, 2018 in Data Analytics by Bharani
• 4,550 points
80 views