str(iris)
data <- iris[, 1:4]
label <- iris[, 5]
# PDI with variance estimation using 50 bootstrap samples
pdi_var(y = label, d = data, method = "multinom", B = 50, trace = FALSE)
## Call:
## pdi_var(y = label, d = data, method = "multinom", B = 50, trace = FALSE)
## Overall Polytomous Discrimination Index:
## 0.9848
## Standard Error:
## 0.0089
## 95% Confidence Interval:
## [0.9674, 1.0000]
## Bootstrap Samples: 50
## Category-specific Polytomous Discrimination Index:
## CATEGORIES VALUES SE LOWER_CI UPPER_CI
## setosa 1.0000 0.0000 1.0000 1.0000
## versicolor 0.9772 0.0133 0.9511 1.0000
## virginica 0.9772 0.0133 0.9511 1.0000
# Using tree method
pdi_var(y = label, d = data, method = "tree", B = 50)
# Using probability matrix directly
require(nnet)
fit <- multinom(label ~ ., data = data.frame(label = label, data),
maxit = 1000, MaxNWts = 2000, trace = FALSE)
predict.probs <- predict(fit, type = "probs")
pp <- data.frame(predict.probs)
pdi_var(y = label, d = pp, method = "prob", B = 50)
Run the code above in your browser using DataLab