Skip to content

Commit

Permalink
fix(F1Score): correct computation of F1Score in automl training
Browse files Browse the repository at this point in the history
- added F1Score to automl training block
- cast labels to float32 to prevent type errors
  • Loading branch information
rizoudal committed Aug 9, 2024
1 parent 84902ee commit bd4cff3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions aucmedi/automl/block_train.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import os
import numpy as np
import json
from tensorflow.keras.metrics import AUC
from tensorflow.keras.metrics import AUC, F1Score
from tensorflow.keras.callbacks import ModelCheckpoint, CSVLogger, \
ReduceLROnPlateau, EarlyStopping
# Internal libraries
Expand Down Expand Up @@ -139,7 +139,7 @@ def block_train(config):
"workers": config["workers"],
"batch_queue_size": 4,
"loss": loss,
"metrics": [AUC(100)],
"metrics": [AUC(100), F1Score(average="macro")],
"pretrained_weights": True,
"multiprocessing": False,
}
Expand Down
2 changes: 1 addition & 1 deletion aucmedi/data_processing/data_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def _get_batches_of_transformed_samples(self, index_array):

# Add classification to batch if available
if self.labels is not None:
batch_stack[1].extend(self.labels[index_array])
batch_stack[1].extend(np.float32(self.labels[index_array]))
# Add sample weight to batch if available
if self.sample_weights is not None:
batch_stack[2].extend(self.sample_weights[index_array])
Expand Down

0 comments on commit bd4cff3

Please sign in to comment.