deep-learning-with-python-notebooks icon indicating copy to clipboard operation
deep-learning-with-python-notebooks copied to clipboard

Obtain F1score, Recall, Confusion Matrix and precison

Open Ariaeimehr opened this issue 2 years ago • 5 comments

0

How can I obtain F1score, Recall, Confusion Matrix and precison in this code.I have used compile and obtained accuracy but i dont know how write the code to obtain these metrics from my model.I would be thankful te help me. for comm_round in range(comms_round):

global_weights = global_model.get_weights()

scaled_local_weight_list = list()

client_names= list(clients_batched.keys()) random.shuffle(client_names)

for client in client_names: local_model = Transformer local_model.compile(loss=tf.keras.losses.CategoricalCrossentropy(), optimizer=tf.keras.optimizers.Adam(learning_rate = 0.001), metrics='acc')

global_model.set_weights(global_weights)

local_model.set_weights(global_weights)

history = local_model.fit(clients_batched[client], epochs=1, verbose=0, callbacks=[checkpoint_callback])

scaling_factor = weight_scalling_factor(clients_batched, client)
scaled_weights = scale_model_weights(local_model.get_weights(), scaling_factor)
scaled_local_weight_list.append(scaled_weights)

K.clear_session()

average_weights = sum_scaled_weights(scaled_local_weight_list)

global_model.set_weights(average_weights)

for(X_test, Y_test) in test_batched: global_acc, global_loss = test_model(test_x, test_y, global_model, comm_round + 1) Also I want to graph the performance of the model on the train and test sets recorded during training using a line plot, one for each of the loss and the classification accuracy.

Ariaeimehr avatar Aug 03 '23 13:08 Ariaeimehr

is this code correct? from sklearn.metrics import classification_report, confusion_matrix y_pred = global_model.predict(X_test) y_pred = np.argmax(y_pred, axis=1) y_test = np.argmax(Y_test, axis=1)

print(classification_report(y_test, y_pred)) print(confusion_matrix(y_test, y_pred))

Ariaeimehr avatar Aug 03 '23 13:08 Ariaeimehr

​ I have received your E-mail——Steven Lee

ifond avatar Aug 03 '23 13:08 ifond

I am Poorva Raut and I am interested in contributing to your project regarding this issue. So can I contribute? If yes, kindly guide me on how to get started or share contribution guidelines

PoorvaRaut avatar Aug 25 '25 09:08 PoorvaRaut

​ I have received your E-mail——Steven Lee

ifond avatar Aug 25 '25 09:08 ifond

Can I contribute to your project and help to resolve this issue?

On Mon, 25 Aug 2025 at 14:36, Steven @.***> wrote:

ifond left a comment (fchollet/deep-learning-with-python-notebooks#225) https://github.com/fchollet/deep-learning-with-python-notebooks/issues/225#issuecomment-3219443879 ​ I have received your E-mail——Steven Lee

— Reply to this email directly, view it on GitHub https://github.com/fchollet/deep-learning-with-python-notebooks/issues/225#issuecomment-3219443879, or unsubscribe https://github.com/notifications/unsubscribe-auth/BBRABACOB6AWONORUYK7HTT3PLG3DAVCNFSM6AAAAACEXFPFHKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTEMJZGQ2DGOBXHE . You are receiving this because you commented.Message ID: @.*** .com>

PoorvaRaut avatar Aug 25 '25 09:08 PoorvaRaut