Given two lists of 1s and 0s (1 represents the true label, and 0 represents the false false) of the same length, output a 2darra | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 2

Given two lists of 1s and 0s (1 represents the true label, and 0 represents the false false) of the same length, output a 2darra

ANS: import numpy as np y_true = [int(x) for x in input().split()] y_pred = [int(x) for x in input().split()] y_true = np.array(list(map(lambda x: 0 if x == 1 else 1, y_true))) y_pred = np.array(list(map(lambda x: 0 if x == 1 else 1, y_pred))) from sklearn.metrics import confusion_matrix print(confusion_matrix(y_pred, y_true).astype(float))

18th Apr 2022, 12:49 PM
Shubham Mandgaonkar
1 Answer
+ 2
Shubham Mandgaonkar , i am not sure what your issue or question is. can you please give us a bit more information. thanks!
18th Apr 2022, 2:11 PM
Lothar
Lothar - avatar