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.