0

Anyone solved this

Given two lists of 1s and 0s (1 represents the true label, and 0 represents the false false) of the same length, output a 2darrary of counts, each cell is defined as follows Top left: Predicted true and actually true (True positive) Top right: Predicted true but actually false (False positive) Bottom left: Predicted false but actually true (False negative) Bottom right: Predicted false and actually false (True negative)

5th May 2021, 9:09 PM
Nikola Trajkoski
Nikola Trajkoski - avatar
4 Antworten
+ 4
y_true = [int(x) for x in input().split()] y_pred = [int(x) for x in input().split()] from sklearn.metrics import confusion_matrix import numpy as np cm = confusion_matrix(y_pred, y_true, labels=[1,0]) print(np.array(cm, dtype='f'))
7th May 2021, 9:56 PM
Mounzer
0
Thanks, I solved it
6th May 2021, 10:49 AM
Nikola Trajkoski
Nikola Trajkoski - avatar
0
y_true = [int(x) for x in input().split()] y_pred = [int(x) for x in input().split()] from sklearn.metrics import confusion_matrix import numpy as np matrix = confusion_matrix(y_pred, y_true, labels=[1,0]) print(np.array(matrix, dtype='f'))
22nd May 2021, 6:56 PM
Orutwa Justine N.
Orutwa Justine N. - avatar
- 1
Do you need advice how to approach this? You could loop over the elements of the lists (index from 0 to list length), classify them (like 00, 01, 10, 11) and increment the respective cell in the 2darray by one. Or for each of the four cells in the 2darray you could count how many rows from the lists match the defined condition for the cell
6th May 2021, 1:52 AM
Benjamin Jürgens
Benjamin Jürgens - avatar