Code Monkey home page Code Monkey logo

Comments (9)

kamilc-bst avatar kamilc-bst commented on June 11, 2024 2

What if I have multi-label classification problem + I want to evaluate my eval dataset via "f1" + specific average strategy like 'weighted' or 'micro' ? Is it supported ?

from setfit.

nsorros avatar nsorros commented on June 11, 2024 2

Currently, we support any classification metric from the evaluate library: https://huggingface.co/docs/evaluate/index

@lewtun one limitation though seems to be that in case of non binary labels there is no way to pass an average strategy. this would need to happen here

return metric_fn.compute(predictions=y_pred, references=y_test)

So in those cases you need to fallback to accuracy or write your own trainer. Would it be in scope to support those evaluations? I am happy to open a PR for this.

from setfit.

jmwoloso avatar jmwoloso commented on June 11, 2024 1

assuming I'm not missing something major, this seems like an easy fix. here's my current implementation that I'm testing. happy to start a formal PR for this if desired @lewtun

https://github.com/huggingface/setfit/compare/main...jmwoloso:setfit:fix_multilabel_metrics?expand=1

EDIT: haven't added tests or anything which i'd need to do, etc. to make this a formal PR which i'm happy to do; this is just to unblock me from using SetFitTrainer at the moment

from setfit.

tomaarsen avatar tomaarsen commented on June 11, 2024 1

You can use "accuracy" or "f1" (now fully supported for multi-label by also using metric_kwargs) as simple low-effort solutions to evaluation, but you can also provide a function if you'd like. See this for more information:

metric (`str` or `Callable`, *optional*, defaults to `"accuracy"`):
The metric to use for evaluation. If a string is provided, we treat it as the metric name and load it with default settings.
If a callable is provided, it must take two arguments (`y_pred`, `y_test`).
metric_kwargs (`Dict[str, Any]`, *optional*):
Keyword arguments passed to the evaluation function if `metric` is an evaluation string like "f1".
For example useful for providing an averaging strategy for computing f1 in a multi-label setting.

I think this should allow for as much flexibility as is required, so I'll close this.

  • Tom Aarsen

from setfit.

lewtun avatar lewtun commented on June 11, 2024

Hi @snayan06 thanks for your interest in setfit! Although accuracy is the default metric, you can specify a different one when you create the SetFitTrainer, e.g.:

from setfit import SetFitTrainer

trainer = SetFitTrainer(model=model, train_dataset=train_dataset, metric="f1")

Currently, we support any classification metric from the evaluate library: https://huggingface.co/docs/evaluate/index

from setfit.

snayan06 avatar snayan06 commented on June 11, 2024

ok thanks for answering , was just looking to contribute and thought that was not there in setfit, and would have been helpful to add. thanks to pointing to the the library as well.

from setfit.

snayan06 avatar snayan06 commented on June 11, 2024

Is there any way u guys track features and people can contribute to build these features, or it is just in the issues , new to open source but have been using huggingface/sbert models from a long time and thought if i can contribute in some way that would be good.

from setfit.

jmwoloso avatar jmwoloso commented on June 11, 2024

shouldn't this line in the same file (and method) handle multi-label though?

metric_config = "multilabel" if self.model.multi_target_strategy is not None else None

from setfit.

joostjansen avatar joostjansen commented on June 11, 2024

I was wondering if there have been any updates as regards computing other metrics for multi label output?

from setfit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.