John Graham Reynolds commited on
Commit
1847cde
β€’
1 Parent(s): 6fdccff

more updates to app

Browse files
Files changed (1) hide show
  1. app.py +17 -13
app.py CHANGED
@@ -1,36 +1,40 @@
1
  from fixed_f1 import FixedF1
2
  from fixed_precision import FixedPrecision
3
  from fixed_recall import FixedRecall
4
-
5
  import gradio as gr
6
 
7
  title = "'Combine' multiple metrics with this πŸ€— Evaluate πŸͺ² Fix!"
8
 
9
  description = """<p style='text-align: center'>
10
- As I introduce myself to the entirety of the πŸ€— ecosystem, I've put together this space to show off a workaround for a current πŸͺ² in the πŸ€— Evaluate library. \n
11
 
12
- Check out the original, longstanding issue [here](https://github.com/huggingface/evaluate/issues/234). This details how it is currently impossible to \
13
  'evaluate.combine()' multiple metrics related to multilabel text classification. Particularly, one cannot 'combine()' the f1, precision, and recall scores for \
14
  evaluation. I encountered this issue specifically while training [RoBERTa-base-DReiFT](https://huggingface.co/MarioBarbeque/RoBERTa-base-DReiFT) for multilabel \
15
- text classification of 805 labeled medical conditions based on drug reviews for treatment received for the same underlying conditio. Use the space below for \
16
- a preview of the workaround! \n
17
 
18
  Try to use \t to write some code? \t or how does that work? </p>
19
 
20
 
21
  """
22
 
23
- article = "<p style='text-align: center'>Check out the [original repo](https://github.com/johngrahamreynolds/FixedMetricsForHF) housing this code, and a quickly \
24
- trained [multilabel text classicifcation model](https://github.com/johngrahamreynolds/RoBERTa-base-DReiFT/tree/main) that makes use of it during evaluation.</p>"
 
 
 
 
 
 
25
 
26
- def show_off(input):
27
- f1 = FixedF1()
28
- precision = FixedPrecision()
29
- recall = FixedRecall()
30
 
 
 
31
 
32
 
33
- return "Checking this out! Here's what you put in: " + f"""{input} """
34
 
35
 
36
  gr.Interface(
@@ -40,5 +44,5 @@ gr.Interface(
40
  title=title,
41
  description=description,
42
  article=article,
43
- examples=[["What are you doing?"], ["Where should we time travel to?"]],
44
  ).launch()
 
1
  from fixed_f1 import FixedF1
2
  from fixed_precision import FixedPrecision
3
  from fixed_recall import FixedRecall
4
+ import evaluate
5
  import gradio as gr
6
 
7
  title = "'Combine' multiple metrics with this πŸ€— Evaluate πŸͺ² Fix!"
8
 
9
  description = """<p style='text-align: center'>
10
+ As I introduce myself to the entirety of the πŸ€— ecosystem, I've put together this space to show off a temporary fix for a current πŸͺ² in the πŸ€— Evaluate library. \n
11
 
12
+ Check out the original, longstanding issue [here](https://github.com/huggingface/evaluate/issues/234). This details how it is currently impossible to \
13
  'evaluate.combine()' multiple metrics related to multilabel text classification. Particularly, one cannot 'combine()' the f1, precision, and recall scores for \
14
  evaluation. I encountered this issue specifically while training [RoBERTa-base-DReiFT](https://huggingface.co/MarioBarbeque/RoBERTa-base-DReiFT) for multilabel \
15
+ text classification of 805 labeled medical conditions based on drug reviews. \n
 
16
 
17
  Try to use \t to write some code? \t or how does that work? </p>
18
 
19
 
20
  """
21
 
22
+ article = "<p style='text-align: center'> Check out the [original repo](https://github.com/johngrahamreynolds/FixedMetricsForHF) housing this code, and a quickly \
23
+ trained [multilabel text classification model](https://github.com/johngrahamreynolds/RoBERTa-base-DReiFT/tree/main) that makes use of it during evaluation.</p>"
24
+
25
+ def show_off(predictions, references, weighting_map):
26
+
27
+ f1 = FixedF1(average=weighting_map["f1"])
28
+ precision = FixedPrecision(average=weighting_map["precision"])
29
+ recall = FixedRecall(average=weighting_map["recall"])
30
 
31
+ combined = evaluate.combine([f1, recall, precision])
 
 
 
32
 
33
+ combined.add_batch(prediction=predictions, reference=references)
34
+ outputs = combined.compute()
35
 
36
 
37
+ return "Your metrics are as follows: \n" + outputs
38
 
39
 
40
  gr.Interface(
 
44
  title=title,
45
  description=description,
46
  article=article,
47
+ examples=[[[1, 0, 2, 0, 1], [1,0,0,0,1], {"f1":"weighted", "precision": "micro", "recall": "weighted"}]],
48
  ).launch()