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 1,201 views

## 1 answer to this question.

• 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

• 4,660 points

## Warning: Error in UseMethod: no applicable method for 'spread_' applied to an object of class "table" in shiny Apps in R

Warning: Error in UseMethod: no applicable method ...READ MORE

## 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

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

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

## 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

## Finding frequency of observations in R

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

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

## Plotting multiple graphs on the same page in R

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

+1 vote

## 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