Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions isic_challenge_scoring/classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class ClassificationMetric(enum.Enum):
BALANCED_ACCURACY = 'balanced_accuracy'
AUC = 'auc'
AVERAGE_PRECISION = 'ap'
DICE = 'dice'


@dataclass(init=False)
Expand Down Expand Up @@ -100,6 +101,24 @@ def __init__(
]
)
self.validation = per_category_auc.mean()
elif target_metric == ClassificationMetric.DICE:
self.overall = self.macro_average.at['dice']
per_category_dice = pd.Series(
[
metrics.binary_dice(
create_binary_confusion_matrix(
truth_binary_values=truth_probabilities[category].gt(0.5).to_numpy(),
prediction_binary_values=prediction_probabilities[category]
.gt(0.5)
.to_numpy(),
weights=truth_weights['validation_weight'].to_numpy(),
name=category,
)
)
for category in categories
]
)
self.validation = per_category_dice.mean()

@staticmethod
def _category_score(
Expand Down
1 change: 1 addition & 0 deletions tests/test_classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
ClassificationMetric.AUC,
ClassificationMetric.BALANCED_ACCURACY,
ClassificationMetric.AVERAGE_PRECISION,
ClassificationMetric.DICE,
],
)
def test_score(classification_truth_file_path, classification_prediction_file_path, target_metric):
Expand Down