+ 1

Data Science - Binary Disorder Confusion matrix of binary classification. For binary classifications, a confusion matrix is a

I didnt get i have tried it like this y_true = [int(x) for x in input().split()] y_pred = [int(x) for x in input().split()] from sklearn.metrics import confusion_matrix from numpy as np y_pred = np.array(y_pred).reshape(-1 , 1) print(confusion_matrix(y_true, y_pred))

26th Jun 2021, 3:38 PM
Om Nandgirwar
Om Nandgirwar - avatar
6 odpowiedzi
+ 14
y_true = [int(x) for x in input().split()] y_pred = [int(x) for x in input().split()] import numpy as np y_true = np.array(y_true) y_pred= np.array(y_pred) tp=sum(y_true & y_pred) fp=sum(~y_true & y_pred) fn=sum(y_true & ~y_pred) tn=len(y_true)-tp-fp-fn print(np.array([[tp,fp],[fn,tn]],dtype='f'))
5th Nov 2021, 6:03 AM
Zura Papiashvili
Zura Papiashvili - avatar
+ 8
import numpy as np from sklearn.metrics import confusion_matrix y_true = [int(x) for x in input().split()] y_pred = [int(x) for x in input().split()] # numpy array y_true = np.array(y_true) y_pred = np.array(y_pred) confusion = confusion_matrix(y_pred, y_true, labels=[1, 0]) print(np.array(confusion, dtype="f"))
16th Jan 2022, 8:05 AM
Kannika
Kannika - avatar
+ 3
import numpy as np from sklearn.metrics import confusion_matrix y_true = [int(x) for x in input().split()] y_pred = [int(x) for x in input().split()] X = [] TL = float(0) TR = float(0) BL = float(0) BR = float(0) for x, y in zip(y_true, y_pred): if x == 1: if y == 1: TL += 1 else: BL += 1 elif x == 0: if y == 1: TR += 1 else: BR += 1 X.append(TL) X.append(TR) X.append(BL) X.append(BR) Y = np.array(X) Y = Y.reshape(2, 2) print(Y) I've tried this. And it works for all the cases..
7th Sep 2021, 7:42 AM
Indah Triwahyuni
Indah Triwahyuni - avatar
0
import numpy as np from sklearn.metrics import confusion_matrix y_true = [int(x) for x in input().split()] y_pred = [int(x) for x in input().split()] X = [] TL = float(0) TR = float(0) BL = float(0) BR = float(0) for x, y in zip(y_true, y_pred): if x == 1: if y == 1: TL += 1 else: BL += 1 elif x == 0: if y == 1: TR += 1 else: BR += 1 X.append(TL) X.append(TR) X.append(BL) X.append(BR) Y = np.array(X) Y = Y.reshape(2, 2) print(Y)
19th Mar 2022, 6:08 AM
TEWODROS WUBETE DESTA
0
TEWODROS WUBETE DESTA what is purpose of confusion_matrix here?
11th Sep 2022, 4:54 AM
Sharofiddin
Sharofiddin - avatar
0
import numpy as np y_true = [int(x) for x in input().split()] y_pred = [int(x) for x in input().split()] conf = list(zip(y_true, y_pred)) def confTuple(tupl, tr,pr): res = len([t[0] for t in tupl if t[0] == tr and t[1]==pr]) return res tp = confTuple(conf, 1,1) fp = confTuple(conf, 0,1) fn = confTuple(conf, 1,0) tn = confTuple(conf, 0,0) print(np.array([[tp,fp],[fn, tn]])/1)
16th Nov 2022, 9:41 AM
Andreas Ströhlein
Andreas Ströhlein - avatar