Hi there, I was able to plot the confusion matrix when I only have 1 class. However, when I have 2 different classes, I couldnt plot the confusion matrix using the code you given, could you tell me what was the problem? I have no idea what i should do to fix this issue....
the actual len of the pred vect is : 102
The actual mean average precision for the whole images (matterport methode): 1.0
the actual len of the gt vect is : 103
the actual len of the pred vect is : 103
The actual mean average precision for the whole images (matterport methode): 1.0
the actual len of the gt vect is : 104
the actual len of the pred vect is : 104
The actual mean average precision for the whole images (matterport methode): 1.0
the actual len of the gt vect is : 105
the actual len of the pred vect is : 105
The actual mean average precision for the whole images (matterport methode): 1.0
the actual len of the gt vect is : 106
the actual len of the pred vect is : 106
The actual mean average precision for the whole images (matterport methode): 1.0
the actual len of the gt vect is : 107
the actual len of the pred vect is : 107
The actual mean average precision for the whole images (matterport methode): 1.0
the actual len of the gt vect is : 108
the actual len of the pred vect is : 108
The actual mean average precision for the whole images (matterport methode): 1.0
the actual len of the gt vect is : 109
the actual len of the pred vect is : 109
The actual mean average precision for the whole images (matterport methode): 1.0
the actual len of the gt vect is : 110
the actual len of the pred vect is : 110
The actual mean average precision for the whole images (matterport methode): 1.0
the actual len of the gt vect is : 111
the actual len of the pred vect is : 111
The actual mean average precision for the whole images (matterport methode): 1.0
the actual len of the gt vect is : 112
the actual len of the pred vect is : 112
The actual mean average precision for the whole images (matterport methode): 1.0
the actual len of the gt vect is : 113
the actual len of the pred vect is : 113
The actual mean average precision for the whole images (matterport methode): 1.0
ValueError Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/pandas/core/internals/managers.py in create_block_manager_from_blocks(blocks, axes)
1670 blocks = [
-> 1671 make_block(values=blocks[0], placement=slice(0, len(axes[0])))
1672 ]
6 frames
/usr/local/lib/python3.7/dist-packages/pandas/core/internals/blocks.py in make_block(values, placement, klass, ndim, dtype)
2743
-> 2744 return klass(values, ndim=ndim, placement=placement)
2745
/usr/local/lib/python3.7/dist-packages/pandas/core/internals/blocks.py in init(self, values, placement, ndim)
130 raise ValueError(
--> 131 f"Wrong number of items passed {len(self.values)}, "
132 f"placement implies {len(self.mgr_locs)}"
ValueError: Wrong number of items passed 2, placement implies 3
During handling of the above exception, another exception occurred:
ValueError Traceback (most recent call last)
in ()
74 #print the confusion matrix and compute true postives, false positives and false negative for each class:
75 #ps : you can controle the figure size and text format by choosing the right values
---> 76 tp, fp, fn = utils.plot_confusion_matrix_from_data(gt_tot, pred_tot, dataset_test.class_names, fz=18, figsize=(20,20), lw=0.5)
77
78 print("mAP: ", np.mean(APs))
/usr/local/lib/python3.7/dist-packages/mask_rcnn-2.1-py3.7.egg/mrcnn/utils.py in plot_confusion_matrix_from_data(y_test, predictions, columns, annot, cmap, fmt, fz, lw, cbar, figsize, show_null_values, pred_val_axis)
354
355 #plot
--> 356 df_cm = DataFrame(confm, index=columns, columns=columns)
357
358 pretty_plot_confusion_matrix(df_cm, fz=fz, cmap=cmap, figsize=figsize, show_null_values=show_null_values,
/usr/local/lib/python3.7/dist-packages/pandas/core/frame.py in init(self, data, index, columns, dtype, copy)
495 mgr = init_dict({data.name: data}, index, columns, dtype=dtype)
496 else:
--> 497 mgr = init_ndarray(data, index, columns, dtype=dtype, copy=copy)
498
499 # For data is list-like, or Iterable (will consume into list)
/usr/local/lib/python3.7/dist-packages/pandas/core/internals/construction.py in init_ndarray(values, index, columns, dtype, copy)
232 block_values = [values]
233
--> 234 return create_block_manager_from_blocks(block_values, [columns, index])
235
236
/usr/local/lib/python3.7/dist-packages/pandas/core/internals/managers.py in create_block_manager_from_blocks(blocks, axes)
1679 blocks = [getattr(b, "values", b) for b in blocks]
1680 tot_items = sum(b.shape[0] for b in blocks)
-> 1681 raise construction_error(tot_items, blocks[0].shape[1:], axes, e)
1682
1683
ValueError: Shape of passed values is (2, 2), indices imply (3, 3)