Question: Compute and Plot the ROC Curve Write a function from scratch called roc _ curve _ computer that accepts ( in this exact order )

Compute and Plot the ROC Curve
Write a function from scratch called roc_curve_computer that accepts (in this exact order):
a list of true labels
a list of prediction probabilities (notice these are probabilities and not predictions - you will need to obtain the predictions from these probabilities using one of your previously created functions)
a list of threshold values.
The function must compute and return the True Positive Rate (TPR, also called recall) and the False Positive Rate (FPR) for each threshold value in the threshold value list that is passed to the function.
Important: Be sure to reuse functions and code segments from your work above! You should reuse two of your above created functions so that you do not duplicate your code.
The function you will write behaves identically to Scikit-Learn's roc_curve function, except that it will take the list of thresholds in as input rather than return them as output. Your function must calculate one value of TPR and one value of FPR for each of the threshold values in the list.
Your function will output a list of TPR values and a list of FPR values (in that order). You will then take these TPR and FPR values, and plot them against each other to create the Receiver Operating Characteristic (ROC) curve.
You must not use any built-in library function to perform the calculation of a performance metric. You may of course use common, built-in Python functions, such as: range(), len(), et cetera.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!