F_beta is calculated as nan

I’m training my model for a dataset given in a competition. The primary metric for evaluation is Mean F1-Score. But when I use fbeta(beta=1), I get a error
metrics = [error_rate, fbeta(beta=1)]
>>> TypeError: fbeta() missing 2 required positional arguments: ‘y_pred’ and ‘y_true’

And while training f_beta is NaN.

Can anyone please tell how do I fix this?

For a metric, you need to pass a function or an instance of one of the fastai metric classes.

fbeta is a function. You are trying to evaluate the fbeta function, instead of constructing a list of two functions. Try this (appears in one of the Lesson notebooks):

f_score = partial(fbeta, beta=1) # f_score is a new function, fbeta with one parameter set
metrics = [error_rate, f_score]

Or use the FBeta class, construct an instance, set its beta, pass the instance as a metric.

HTH.

1 Like

Thanks.

Hi ,

I am also trying to calculate mean F1 score.The function mentioned above calculates the F1 score.How do you calculate the Mean F1 score.

Thanks ,
Akalya