0

I am building a image predicting model.

To get the better picture of the accuracy I am printing a confusion matrix using scikit learn.

When I was using 30 classes, the confusion matrix was completely displayed in the print screen, but as soon as I use my model on 50 classes, it starts to print truncated/shrinked versions of the confusion matrix.

I tried different ways to print it complete or write it into the file, but it did not work.

The output is something like this:

[[0 0 0 ... 0 0 0]
[0 0 0 ... 0 0 0]
[0 0 0 ... 0 0 0]
...
[0 0 0 ... 0 0 0]
[0 0 0 ... 0 0 0]
[0 0 0 ... 0 0 0]]

I also tried np.set_printoptions. but it does not work either.

With np.set_printoptions it is not even letting me print anything and I get errors like: typeError can not implement between int and str.

Alexander Egger
  • 5,132
  • 1
  • 28
  • 42

2 Answers2

0

You can print complete array without truncating by setting

np.set_printoptions(threshold=np.inf)

or

np.set_printoptions(threshold=np.nan)

By default arrays larger than 1000 elements will be truncated.

For full documentation, see http://docs.scipy.org/doc/numpy/reference/generated/numpy.set_printoptions.html.

Kamil Mahmood
  • 527
  • 9
  • 22
0

You can convert you array to a list and then print it:

my_list = my_array.tolist()
Martin Thoma
  • 124,992
  • 159
  • 614
  • 958