0

I have data that has entries assigned to one out of four classes and I'm training a feed forward neural network on it. So far I have the following code, that gives me the overall accuracy. But I want to get the accuracy for each class.

np.random.seed(0)

number_of_features = 1

train_features = punct_array
test_features = punct_gold_array


# Start neural network
network = models.Sequential()

# Add fully connected layer with a ReLU activation function
network.add(layers.Dense(units=16, activation='relu', input_shape=(number_of_features,)))

# Add fully connected layer with a ReLU activation function
network.add(layers.Dense(units=16, activation='relu'))

# Add fully connected layer with a sigmoid activation function
network.add(layers.Dense(units=4, activation='softmax'))



# Compile neural network
network.compile(loss='sparse_categorical_crossentropy', # Cross-entropy
                optimizer='adam', # Root Mean Square Propagation
                metrics=[metrics.mae, metrics.categorical_accuracy])



# Train neural network
history = network.fit(train_features, # Features
                      Label_array, # Target vector
                      epochs=40, # Number of epochs
                      verbose=1, # Print description after each epoch
                      batch_size=16, # Number of observations per batch
                      validation_data=(test_features, goldLabel_array))

The classes are labeled 0, 1, 2, and 3.

maybeyourneighour
  • 494
  • 2
  • 4
  • 13
  • seems to be a duplicate but matrix = metrics.confusion_matrix(y_test.argmax(axis=1), y_pred.argmax(axis=1)) From : https://stackoverflow.com/questions/50920908/get-confusion-matrix-from-a-keras-multiclass-model – iampotential Aug 04 '19 at 17:17
  • Possible duplicate of [Get Confusion Matrix From a Keras Multiclass Model](https://stackoverflow.com/questions/50920908/get-confusion-matrix-from-a-keras-multiclass-model) – iampotential Aug 04 '19 at 17:18

0 Answers0