title: How do I find the false positive and false negative rates for a neural network?
body: <p>I have the below code which works perfectly for a neural network. I know I need the confusion matrix library to find the false positive and false negative rates but I'm not sure how to do it as I'm no expert in programming. Can someone help please?</p>
  <pre><code>import pandas as pd
  from sklearn import preprocessing
  from sklearn.metrics import confusion_matrix
  from sklearn.model_selection import train_test_split
  from keras.models import Sequential
  from keras.layers import Dense
  
  # read the csv file and convert into arrays for the machine to process
  df = pd.read_csv('dataset_ori.csv')
  dataset = df.values
  
  # split the dataset into input features and the feature to predict
  X = dataset[:,0:7]
  Y = dataset[:,7]
  
  # scale the dataset using sigmoid function min_max_scaler so that all the input features lie between 0 and 1
  min_max_scaler = preprocessing.MinMaxScaler()
  
  # store the dataset into an array
  X_scale = min_max_scaler.fit_transform(X)
  
  # split the dataset into 30% testing and the rest to train
  X_train, X_val_and_test, Y_train, Y_val_and_test = train_test_split(X_scale, Y, test_size=0.3)
  
  # split the val_and_test size equally to the validation set and the test set.
  X_val, X_test, Y_val, Y_test = train_test_split(X_val_and_test, Y_val_and_test, test_size=0.5)
  
  # specify the sequential model and describe the layers that will form architecture of the neural network
  model = Sequential([Dense(7, activation='relu', input_shape=(7,)), Dense(32, activation='relu'), Dense(5, activation='relu'), Dense(1, activation='sigmoid'),])
  model.compile(optimizer='adam', loss='binary_crossentropy', metrics=['accuracy'])
  
  # training the data
  hist = model.fit(X_train, Y_train, batch_size=32, epochs=100, validation_data=(X_val, Y_val))
  
  # to find the accuracy of the mf the classifier
  scores = model.evaluate(X_test, Y_test)
  
  print(&quot;Accuracy: %.2f%%&quot; % (scores[1]*100))
  </code></pre>
  <p>This is the code provided in the answer below. response, model are both highlighted with red for unreslove references</p>
  <pre><code>from keras import models
  from keras.layers import Dense, Dropout
  from keras.utils import to_categorical
  import numpy as np # linear algebra
  import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
  from keras.models import Sequential
  from keras.layers import Dense, Activation
  from sklearn import metrics
  from sklearn.preprocessing import StandardScaler
  
  
  # read the csv file and convert into arrays for the machine to process
  df = pd.read_csv('dataset_ori.csv')
  dataset = df.values
  
  # split the dataset into input features and the feature to predict
  X = dataset[:,0:7]
  Y = dataset[:,7]
  
  # Splitting into Train and Test Set
  from sklearn.model_selection import train_test_split
  X_train, X_test, y_train, y_test = train_test_split(dataset,
                                                      response,
                                                      test_size = 0.2,
                                                      random_state = 0)
  
  # Initialising the ANN
  classifier = Sequential()
  
  # Adding the input layer and the first hidden layer
  classifier.add(Dense(units = 10, kernel_initializer = 'uniform', activation = 'relu', input_dim =7 ))
  model.add(Dropout(0.5))
  # Adding the second hidden layer
  classifier.add(Dense(units = 10, kernel_initializer = 'uniform', activation = 'relu'))
  model.add(Dropout(0.5))
  # Adding the output layer
  classifier.add(Dense(units = 1, kernel_initializer = 'uniform', activation = 'sigmoid'))
  
  # Compiling the ANN
  classifier.compile(optimizer = 'adam', loss = 'sparse_categorical_crossentropy', metrics = ['accuracy'])
  
  # Fitting the ANN to the Training set
  classifier.fit(X_train, y_train, batch_size = 10, epochs = 20)
  
  # Train model
  scaler = StandardScaler()
  classifier.fit(scaler.fit_transform(X_train.values), y_train)
  
  # Summary of neural network
  classifier.summary()
  
  # Predicting the Test set results &amp; Giving a threshold probability
  y_prediction = classifier.predict_classes(scaler.transform(X_test.values))
  print (&quot;\n\naccuracy&quot; , np.sum(y_prediction == y_test) / float(len(y_test)))
  y_prediction = (y_prediction &gt; 0.5)
  
  
  #Let's see how our model performed
  from sklearn.metrics import classification_report
  print(classification_report(y_test, y_prediction))
  
  </code></pre>