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
• 420 points
1,406 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,660 points

Related Questions In Data Analytics

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 6, 2019 in Data Analytics by anonymous
14,081 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,250 points
3,813 views
0 votes
2 answers

R function for finding the index of an element in a vector?

The function match works on vectors : x <- sample(1:10) x # ...READ MORE

answered Dec 12, 2020 in Data Analytics by Rajiv
• 8,870 points
56,616 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,660 points
5,886 views
0 votes
1 answer

Left Join and Right Join using "dplyr"

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

answered Mar 27, 2018 in Data Analytics by Bharani
• 4,660 points
1,097 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,660 points
1,422 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, 2019 in Data Analytics by anonymous
1,929 views
0 votes
2 answers

Installing MXNet for R in Windows System

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

answered Dec 4, 2018 in Data Analytics by Kalgi
• 52,350 points
2,411 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,660 points
1,168 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP