Constructing a confusion matrix from data without sklearn
问题 I am trying to construct a confusion matrix without using the sklearn library. I am having trouble correctly forming the confusion matrix. Here's my code: def comp_confmat(): currentDataClass = [1,3,3,2,5,5,3,2,1,4,3,2,1,1,2] predictedClass = [1,2,3,4,2,3,3,2,1,2,3,1,5,1,1] cm = [] classes = int(max(currentDataClass) - min(currentDataClass)) + 1 #find number of classes for c1 in range(1,classes+1):#for every true class counts = [] for c2 in range(1,classes+1):#for every predicted class count