Finally, we use the R glm() function to apply Logistic Regression on our dataset.We have set certain error metrics to evaluate the functioning of the model which includes Precision, Recall, Accuracy, F1 score, ROC plot, etc.Thus, we sample the dataset into training and test data values using createDataPartition() function from the R documentation. Splitting of dataset is a crucial step prior to modelling.Initially, we load the dataset into the environment using read.csv() function.We would be plotting the ROC curve using plot() function from the ‘ pROC’ library. In this example, we would be using the Bank Loan defaulter dataset for modelling through Logistic Regression. So, let us try implementing the concept of ROC curve against the Logistic Regression model. We can use ROC plots to evaluate the Machine learning models as well as discussed earlier. Let us now try to implement the concept of ROC curve in the upcoming section!
![cplot in r cplot in r](https://statisticsglobe.com/wp-content/uploads/2020/11/figure-6-plot-plot-composition-using-patchwork-package-in-r.png)
In technical terms, the ROC curve is plotted between the True Positive Rate and the False Positive Rate of a model. So, if the AUC score is high, it indicates that the model is capable of classifying ‘Heads’ as ‘Heads’ and ‘Tails’ as ‘Tails’ more efficiently. Higher the AUC score, better is the classification of the predicted values.įor example, consider a model to predict and classify whether the outcome of a toss is ‘Heads’ or ‘Tails’. With ROC AUC curve, one can analyze and draw conclusions as to what amount of values have been distinguished and classified by the model rightly according to the labels.
![cplot in r cplot in r](https://moderndata.plotly.com/wp-content/uploads/2015/04/Screen-Shot-2015-04-24-at-1.42.44-PM.png)
To be precise, ROC curve represents the probability curve of the values whereas the AUC is the measure of separability of the different groups of values/labels. That is, it measures the functioning and results of the classification machine learning algorithms.
![cplot in r cplot in r](https://statisticsglobe.com/wp-content/uploads/2019/10/figure-7-multiple-lines-in-graph-different-pch-plot-function-in-R-programming-language-1024x768.png)
ROC plot, also known as ROC AUC curve is a classification error metric. Hello, folks! In this article, we will be having a look at an important error metric of Machine Learning – Plotting ROC curve in R programming, in detail.Įrror metrics enable us to evaluate and justify the functioning of the model on a particular dataset.