0

Machine Learning Model Evaluation Module :: project :: Welcome to the Matrix Test case 5

help plezz i am trying to run this code and it passed all test cases except 5 which is hidden : tp, fp, fn, tn = [int(x) for x in input().split()] total = tp + fp + fn + tn accuracy = round((tp + tn) / total,4) precision = round(tp / (tp + fp) ,4) recall = round(tp / (tp + fn),4) f1 = round( 2 * precision * recall / (precision + recall) ,4) print(accuracy) print(precision) print(recall) print(f1)

16th Feb 2021, 3:47 PM
Sekrafi Nawfel
Sekrafi Nawfel - avatar
11 Respostas
+ 11
Round in the print statement, not on "the way" - rounding errors may occur else ways Rounding errors are adding up For example, if we take 1.3 as précision and recall and round them both to whole numbers when we calculate them. => we get 1, 1*1 =1 instead of 1.3*1.3 = 1.69 =>rounded to 2
20th Feb 2021, 10:21 PM
StephBill
StephBill - avatar
+ 11
As StephBill said, I rounded in the print statement and not on the way (it worked!): tp, fp, fn, tn = [int(x) for x in input().split()] total = tp+ fp+ fn+ tn accuracy = (tp + tn )/(total) #round(x, 4) precision = tp/ (tp+fp) recall = tp/ (tp+fn) f1 = round(1/(((1/precision) + (1/recall)) / 2), 4) print(round(accuracy, 4)) print(round(precision, 4)) print(round(recall, 4)) print(f1)
24th Apr 2021, 10:15 PM
Ankit Ranjan
+ 1
tp, fp, fn, tn = [int(x) for x in input().split()] total = tp + fp + fn + tn accuracy = round((tp + tn) / total,4) precision = round(tp / (tp + fp) ,4) recall = round(tp / (tp + fn),4) f1 = round( 2 * precision * recall / (precision + recall) ,4) print(accuracy) print(precision) print(recall) print(f1) not working test case 5 is hidden and shows wrong
16th Apr 2021, 2:16 AM
Mirchi Tadka
Mirchi Tadka - avatar
+ 1
tp, fp, fn, tn = [int(x) for x in input().split()] total = tp+ fp+ fn+ tn accuracy = (tp + tn )/(total) #round(x, 4) precision = tp/ (tp+fp) recall = tp/ (tp+fn) f1 = round(1/(((1/precision) + (1/recall)) / 2), 4) print(round(accuracy, 4)) print(round(precision, 4)) print(round(recall, 4)) print(f1)
6th May 2021, 4:30 AM
Md. Rakibul Islam
Md. Rakibul Islam - avatar
0
please answer for this problem.
20th Feb 2021, 9:46 PM
Mustafa ONER
Mustafa ONER - avatar
0
tp, fp, fn, tn = [int(x) for x in input().split()] total = tp+ fp+ fn+ tn accuracy = (tp + tn )/(total) #round(x, 4) precision = tp/ (tp+fp) recall = tp/ (tp+fn) f1 = round(1/(((1/precision) + (1/recall)) / 2), 4) print(round(accuracy, 4)) print(round(precision, 4)) print(round(recall, 4)) print(f1)
8th Dec 2021, 3:20 AM
Nabila Muftia Ma'ruf Kartono
Nabila Muftia Ma'ruf Kartono - avatar
0
tp, fp, fn, tn = [int(x) for x in input().split()] total = tp+ fp+ fn+ tn accuracy = (tp + tn )/(total) #round(x, 4) precision = tp/ (tp+fp) recall = tp/ (tp+fn) f1 = round(1/(((1/precision) + (1/recall)) / 2), 4) print(round(accuracy, 4)) print(round(precision, 4)) print(round(recall, 4)) print(f1)
15th Dec 2021, 4:48 PM
Mirmahmud Ilyosov
Mirmahmud Ilyosov - avatar
0
tp, fp, fn, tn = [int(x) for x in input().split()] total = tp+ fp+ fn+ tn accuracy = (tp + tn )/(total) #round(x, 4) precision = tp/ (tp+fp) recall = tp/ (tp+fn) f1 = round(1/(((1/precision) + (1/recall)) / 2), 4) print(round(accuracy, 4)) print(round(precision, 4)) print(round(recall, 4)) print(f1)
17th Dec 2021, 10:03 AM
Ismoilov Abdug'ofur
Ismoilov Abdug'ofur - avatar
0
I passed all the test cases using these codes, I hope this might help you tp, fp, fn, tn = [int(x) for x in input().split()] ac = (tp + tn) / (tp+fp+fn+tn) pr = tp / (tp + fp) re = tp / (tp + fn) f1 = (2 * pr * re) / (pr + re) output = [ac, pr, re, f1] for i in output: print(round(i, 4))
13th Jun 2022, 4:44 AM
Poornima
0
tp, fp, fn, tn = [int(x) for x in input().split()] total = tp + tn + fp + fn #Accuracy is (tp + tn) / total accuracy = (tp + tn) / total #Precision is tp / (tp + fp) precision = tp / (tp + fp) #Recall is tp / (tp + fn) recall = tp / (tp + fn) #F1 score is 2 * precision * recall / (precision + recall) f1 = 2 * precision * recall / (precision + recall) print(round(accuracy, 4)) print(round(precision, 4)) print(round(recall, 4)) print(round(f1, 4))
29th Jul 2022, 10:08 PM
Ernesto Avila Domenech
Ernesto Avila Domenech - avatar
0
tp, fp, fn, tn = [int(x) for x in input().split()] total = tp+ fp+ fn+ tn accuracy = (tp + tn )/(total) #round(x, 4) precision = tp/ (tp+fp) recall = tp/ (tp+fn) f1 = round(1/(((1/precision) + (1/recall)) / 2), 4) print(round(accuracy, 4)) print(round(precision, 4)) print(round(recall, 4)) print(f1)
16th Feb 2023, 7:39 AM
Kawlakari Sumathi
Kawlakari Sumathi - avatar