confusion-matrix

Constructing a confusion matrix from data without sklearn

房东的猫 提交于 2020-05-31 07:07:10
问题 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

python tabulating confusion matrix

亡梦爱人 提交于 2020-05-28 07:35:03
问题 In my sklearn logistic regression model, I obtained a confusion matrix using metrics.confusion_matrix command. The array looks like this array([[51, 0], [26, 0]]) Ignoring the fact that the model did pretty bad, I am trying to understand what is the best way to tabulate this matrix in pretty way I am trying to use tabulate package and this code partially works for me print tabulate(cm,headers=['Pred True', 'Pred False']) as it gives output Pred True Pred False ----------- ------------ 51 0 26

python tabulating confusion matrix

二次信任 提交于 2020-05-28 07:34:31
问题 In my sklearn logistic regression model, I obtained a confusion matrix using metrics.confusion_matrix command. The array looks like this array([[51, 0], [26, 0]]) Ignoring the fact that the model did pretty bad, I am trying to understand what is the best way to tabulate this matrix in pretty way I am trying to use tabulate package and this code partially works for me print tabulate(cm,headers=['Pred True', 'Pred False']) as it gives output Pred True Pred False ----------- ------------ 51 0 26

python tabulating confusion matrix

偶尔善良 提交于 2020-05-28 07:33:16
问题 In my sklearn logistic regression model, I obtained a confusion matrix using metrics.confusion_matrix command. The array looks like this array([[51, 0], [26, 0]]) Ignoring the fact that the model did pretty bad, I am trying to understand what is the best way to tabulate this matrix in pretty way I am trying to use tabulate package and this code partially works for me print tabulate(cm,headers=['Pred True', 'Pred False']) as it gives output Pred True Pred False ----------- ------------ 51 0 26

python tabulating confusion matrix

早过忘川 提交于 2020-05-28 07:33:06
问题 In my sklearn logistic regression model, I obtained a confusion matrix using metrics.confusion_matrix command. The array looks like this array([[51, 0], [26, 0]]) Ignoring the fact that the model did pretty bad, I am trying to understand what is the best way to tabulate this matrix in pretty way I am trying to use tabulate package and this code partially works for me print tabulate(cm,headers=['Pred True', 'Pred False']) as it gives output Pred True Pred False ----------- ------------ 51 0 26

R how to visualize confusion matrix using the caret package

风流意气都作罢 提交于 2020-05-24 08:48:12
问题 I'd like to visualize the data I've put in the confusion matrix. Is there a function I could simply put the confusion matrix and it would visualize it (plot it)? Example what I'd like to do(Matrix$nnet is simply a table containing results from the classification): Confusion$nnet <- confusionMatrix(Matrix$nnet) plot(Confusion$nnet) My Confusion$nnet$table looks like this: prediction (I would also like to get rid of this string, any help?) 1 2 1 42 6 2 8 28 回答1: You could use the built-in

R how to visualize confusion matrix using the caret package

自作多情 提交于 2020-05-24 08:47:11
问题 I'd like to visualize the data I've put in the confusion matrix. Is there a function I could simply put the confusion matrix and it would visualize it (plot it)? Example what I'd like to do(Matrix$nnet is simply a table containing results from the classification): Confusion$nnet <- confusionMatrix(Matrix$nnet) plot(Confusion$nnet) My Confusion$nnet$table looks like this: prediction (I would also like to get rid of this string, any help?) 1 2 1 42 6 2 8 28 回答1: You could use the built-in

arrays TP, TN, FP and FN in Python

自古美人都是妖i 提交于 2020-05-17 06:33:30
问题 My prediction results look like this TestArray [1,0,0,0,1,0,1,...,1,0,1,1], [1,0,1,0,0,1,0,...,0,1,1,1], [0,1,1,1,1,1,0,...,0,1,1,1], . . . [1,1,0,1,1,0,1,...,0,1,1,1], PredictionArray [1,0,0,0,0,1,1,...,1,0,1,1], [1,0,1,1,1,1,0,...,1,0,0,1], [0,1,0,1,0,0,0,...,1,1,1,1], . . . [1,1,0,1,1,0,1,...,0,1,1,1], this is the size of the arrays that I have TestArray.shape Out[159]: (200, 24) PredictionArray.shape Out[159]: (200, 24) I want to get TP, TN, FP and FN for these arrays I tried this code cm

arrays TP, TN, FP and FN in Python

余生颓废 提交于 2020-05-17 06:32:24
问题 My prediction results look like this TestArray [1,0,0,0,1,0,1,...,1,0,1,1], [1,0,1,0,0,1,0,...,0,1,1,1], [0,1,1,1,1,1,0,...,0,1,1,1], . . . [1,1,0,1,1,0,1,...,0,1,1,1], PredictionArray [1,0,0,0,0,1,1,...,1,0,1,1], [1,0,1,1,1,1,0,...,1,0,0,1], [0,1,0,1,0,0,0,...,1,1,1,1], . . . [1,1,0,1,1,0,1,...,0,1,1,1], this is the size of the arrays that I have TestArray.shape Out[159]: (200, 24) PredictionArray.shape Out[159]: (200, 24) I want to get TP, TN, FP and FN for these arrays I tried this code cm

Plot Confusion Matrix with scikit-learn without a Classifier

给你一囗甜甜゛ 提交于 2020-05-15 04:06:03
问题 I have a confusion matrix created with sklearn.metrics.confusion_matrix . Now, I would like to plot it with sklearn.metrics.plot_confusion_matrix , but the first parameter is the trained classifier, as specified in the documentation. The problem is that I don't have a classifier; the results were obtained doing manual calculations. Is it still possible to plot the confusion matrix in one line via scikit-learn, or do I have to code it myself with matplotlib? Thanks in advance! 回答1: The fact