Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

As an example, calling the roc_curve_computer function with the input true_labels = [1, 0, 1, 0, 0], pred_probs = [0.875, 0.325, 0.6, 0.09, 0.4], and

As an example, calling the roc_curve_computer function with the input true_labels = [1, 0, 1, 0, 0], pred_probs = [0.875, 0.325, 0.6, 0.09, 0.4], and thresholds = [0.00, 0.25, 0.50, 0.75, 1.00] yields the output TPR = [1.0, 1.0, 1.0, 0.5, 0.0] and FPR = [1.0, 0.6666, 0.0, 0.0, 0.0].

I have a these two functions that i need to combine to find those answers.

def predict(): probs = input("Input list of prediction probabilities: ") thresh = input("Input threshold value: ") list1 = probs.split(",") list2 = [] answer = 0 for i in list1: if i < thresh: answer = 0 else: answer = 1 list2.append(answer) print("Model Predictions: ", list2)

def TPR_FPR_score(): labels = input("Input true lables: ") preds = input("input model predictions: ") labels = labels.split(",") preds = preds.split(",") TrueP = [loop1 for loop1 in range(len(labels)) if labels[loop1]=='1' and preds[loop1]== '1'] FalseP = [loop1 for loop1 in range(len(labels)) if labels[loop1]== '0' and preds[loop1]== '1'] FalseN = [loop1 for loop1 in range(len(labels)) if labels[loop1]== '1' and preds[loop1]== '0'] TrueN = [loop1 for loop1 in range(len(labels)) if labels[loop1]== '0' and preds[loop1]== '0'] TP = len(TrueP) FP = len(FalseP) FN = len(FalseN) TN = len(TrueN)

TPR = TP / (TP + FN) ## 7 / (7 + 2) FPR = FP / (FP + TN) ## 2 / (2 + 10) print("TPR = ", TPR) print("FPR = ", FPR) TPR_FPR_score()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MySQL/PHP Database Applications

Authors: Jay Greenspan, Brad Bulger

1st Edition

978-0764535376

More Books

Students also viewed these Databases questions

Question

What is the principle of thermodynamics? Explain with examples

Answered: 1 week ago

Question

Explain the service recovery paradox.

Answered: 1 week ago