Area Under Curve in R, when the response variable is binary, we utilize logistic regression as a statistical method to fit a regression model.
Area Under Curve in R
The following two metrics can be used to determine how well a logistic regression model fits a dataset.
Sensitivity: The likelihood that the model correctly predicts a positive result for observation when the result is positive. The “real positive rate” is another term for this.
Specificity: Refers to the likelihood that the model correctly predicts a negative consequence for an observation. The “real negative rate” is another name for this.
Making a ROC curve, which stands for the “receiver operating characteristic” curve, is one technique to illustrate these two measures.
The sensitivity is plotted on the y-axis, while (1 – specificity) is plotted on the x-axis. Calculating AUC, or “area under the curve,” is one approach to measure how well the logistic regression model works at classifying data.
#install.packages("ISLR")
library(ISLR)
df <- ISLR::Default
head(df)
default student balance income 1 No No 729.5265 44361.625 2 No Yes 817.1804 12106.135 3 No No 1073.5492 31767.139 4 No No 529.2506 35704.494 5 No No 785.6559 38463.496 6 No Yes 919.5885 7491.559
auc(response, predicted)