Metric name?

Hi,

What is the easiest way to change the displayed name of a metric? I have multiple FBeta (with different thresholds) and I’d like to name them differently. I tried doing
m.name = 'new_name'

but I get
AttributeError: can't set attribute

Thanks!

1 Like

It might have implemented a setter? I’m not familiar with the object, but did you try something like:

m.name.set('new_name')

Nope… doesn’t work :frowning:

Are you working with this: Metrics on fast.ai docs?

And what exactly are you trying to do? More info might help.

If you’re familiar with Python, you could subclass fast.ai’s Metric and add a different __str__() method to it that displays what you want when printing out. But that would just be cosmetic and I don’t really know why you want to do what you mentioned.

Disclaimer: there might be a great way to do this and a perfect use case. I couldn’t find anything quickly in the docs I linked up there, but I’m also quite new to using the library, so ¯\_(ツ)_/¯

I did read the docs on metrics, but there is nothing on changing the name unfortunately.

My use case is as I described above: I want to measure FBeta scores but with multiple, different thresholds. If I just add them as metrics, they are all named just “f_beta_score”, but I want them named: “f_beta_at_0.5”, “f_beta_at_0.25” etc :slight_smile:

I can create my own metric and change its name by doing self.__name__ = 'blah', but then I’d like to use fastai’s FBeta, so I store in my own metric:
self.metric = FBetaMulti(2)

And replace __call__:

def __call__(self, inp, targ):
    return self.metric(inp,targ)

But this yields:

ValueError: Classification metrics can't handle a mix of multilabel-indicator and continuous-multioutput targets

which is an error in scikit-learn. Which means I have no idea what metrics is doing under the hood… :frowning:

1 Like

If you are using fastai1, did you try such method:

self.learn.recorder.add_metric_names(['used', 'max_used', 'peak'])