#Load a dataset library(mlbench) data(Sonar) #Build a model library(caret) model <- train(Class~., data=Sonar, method='gbm', tuneLength=1, trControl=trainControl(method='cv')) model #ROC curve and AUC library(pROC) pMal <- predict(model, newdata=Sonar, type='prob')[,2] roc(Sonar$Class, pMal, plot=TRUE) >Area under the curve: 0.9705 #Lorez curve and gini?
In a similar manner, I would like to be able to plot the lorenz curve and calculate the gini coefficient for my classifier. I know
Gini = 2*AUC-1, but I'm not actually sure how to calculate it on it's own. Furthermore, every application of a lorenz curve I've seen looks at univariate data (e.g. income distribution). How do I calculate a lorenz curve when I have 2 parameters: the predicted probability of the positive class, and the positive class itself?