ultrasound-nerve-segmentation icon indicating copy to clipboard operation
ultrasound-nerve-segmentation copied to clipboard

How to print out f1 score?

Open lowkeygit opened this issue 7 years ago • 2 comments

Hello @jocicmarko , Excellent code. I'm trying to reimplement your code. I notice that in the method of model compile, you set loss function to dice_coef_loss and the metrics is dice_coef. model.compile(optimizer=Adam(lr=1e-5), loss=dice_coef_loss, metrics=[dice_coef]) If I want to print out both dice coefficient and f1 score, how do I achieve that? Here I define the f1 score function as follow:

def f1score(y_true, y_pred):
    return f1_score(y_true, y_pred, average=None)

Hope you will give me some advices. Looking forward to your reply. Sincerely,

lowkeygit avatar Sep 23 '17 17:09 lowkeygit

Metric has to be defined with Keras tensors and ops, which means you have to implement it yourself. Also, another solution is a bit hacky, but you can make a Keras custom callback function which will output results of the validation/test set and calculate all the metrics you need with basic numpy/scikit-learn.

jocicmarko avatar Oct 04 '17 11:10 jocicmarko

hi, iam taking some of the training data as a test data. How can i calculate accuracy of the testdata. please any one can you help me.

sreevasu avatar Nov 20 '17 18:11 sreevasu