title: Getting error when creating a Confusion Matrix using scikit learn
body: <p>I am trying to classify cancers into <code>benign</code> and <code>malignant</code> using a pre-trained model <code>Resnet50</code>.</p>
  <p>Here is the code for the model.</p>
  <pre><code>data_path = '/content/drive/My Drive/data'
  data_dir_list = os.listdir(data_path)
  
  img_data_list = []    
  
  for dataclass in data_dir_list:
      img_list = os.listdir(data_path+&quot;/&quot;+dataclass)
      for img in img_list:
          img_path = data_path+&quot;/&quot;+dataclass+&quot;/&quot;+img
          img=image.load_img(img_path, target_size=(224, 224))
          x=image.img_to_array(img)
          x=np.expand_dims(x,axis=0)
          x=preprocess_input(x)
          img_data_list.append(x)
          img_data=np.array(img_data_list)
  
          img_data=np.rollaxis(img_data,1,0)
          img_data= img_data[0]
  
          num_classes=2
          num_of_sample=250
          labels=np.ones(250,dtype='int64')
          labels[0:100]=0
          labels[100:250]=1
          names=['benign', 'malignant']
  
          Y=np_utils.to_categorical(labels, num_classes)
          x,y = shuffle(img_data, Y, random_state=3)
          X_train,X_test,y_train,y_test = train_test_split(x,y,test_size=0.2,random_state=3)
  
          image_input = Input(shape=(224,224,3))
  
          model = ResNet50(input_tensor=image_input, include_top='True', weights='imagenet')
          last_layer = model.get_layer('avg_pool').output
          x=Flatten(name='flattern')(last_layer)
          out=Dense(2, activation='softmax', name='output_layer')(x)
  
          custom_resnet_model = Model(inputs = image_input, outputs=out)
  
          for layer in custom_resnet_model.layers[:-1]:
              layer.trainable = False
  
              custom_resnet_model.layers[-1].trainable
  
              custom_resnet_model.compile(loss='binary_crossentropy', optimizer='rmsprop', metrics=['accuracy'])
  
              hist=custom_resnet_model.fit(X_train,y_train, batch_size=32, epochs=100, steps_per_epoch=7,  
              validation_data=(X_test,y_test))
  </code></pre>
  <p>Then I tried to create a confusion matrix for this model using scikit learn. But I am getting an error.</p>
  <p>Here is the code for the confusion matrix.</p>
  <pre><code>prediction = model.predict_generator(test_set, steps=2 )
  
  rounded_prediction = np.argmax(prediction, axis=-1)
  
  cm = confusion_matrix(y_true=y_test , y_pred=rounded_prediction)
  </code></pre>
  <p>Error:</p>
  <pre><code>ValueError                                Traceback (most recent call last)
  &lt;ipython-input-96-1965da59b466&gt; in &lt;module&gt;()
  ----&gt; 1 cm = confusion_matrix(y_true=y_test , y_pred=rounded_prediction)
  
  1 frames
  /usr/local/lib/python3.7/dist-packages/sklearn/metrics/_classification.py in _check_targets(y_true, y_pred)
       88     if len(y_type) &gt; 1:
       89         raise ValueError(&quot;Classification metrics can't handle a mix of {0} &quot;
  ---&gt; 90                          &quot;and {1} targets&quot;.format(type_true, type_pred))
       91 
       92     # We can't have more than one value on y_type =&gt; The set is no more needed
  
  ValueError: Classification metrics can't handle a mix of multilabel-indicator and binary targets
  </code></pre>
  <p>As I think there is an issue with <code>y_true</code> or <code>y_pred</code>. what is the value for this parameters according to my model. Here I used <code>rounded_prediction</code> for selecting most probable prediction for each sample.</p>
  <p>Data types:</p>
  <pre><code>type(y_test)
  numpy.ndarray
  
  type(rounded_prediction)
  numpy.ndarray
  </code></pre>