John Graham Reynolds commited on
Commit
8a9fb11
·
1 Parent(s): 9a8c7c5

add a second example and clean up

Browse files
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -8,7 +8,7 @@ from fixed_f1 import FixedF1
8
  from pathlib import Path
9
 
10
  added_description = """
11
- See the HF Space showing off how to combine various metrics here:
12
  [MarioBarbeque/CombinedEvaluationMetrics](https://huggingface.co/spaces/MarioBarbeque/CombinedEvaluationMetrics)
13
 
14
  In the specific use case of the `F1Fixed` metric, one writes the following:\n
@@ -20,7 +20,7 @@ f1.add_batch(predictions=..., references=...)
20
  f1.compute()
21
  ```\n
22
 
23
- where the `average` parameter can be different at instantiation time for each of the metrics. Acceptable values include `[None, 'micro', 'macro', 'weighted']` (
24
  or `binary` if there exist only two labels). \n
25
  """
26
 
@@ -33,7 +33,9 @@ else:
33
  gradio_input_types = infer_gradio_input_types(feature_types)
34
 
35
  local_path = Path(sys.path[0])
36
- test_cases = [ {"predictions":[1,2,3,4,5], "references":[1,2,5,4,3]} ] # configure this randomly using randint generator and feature names?
 
 
37
 
38
  # configure this based on the input type, etc. for launch_gradio_widget
39
  def compute(input_df: pd.DataFrame, method: str):
@@ -70,9 +72,13 @@ space = gr.Interface(
70
  article=parse_readme(local_path / "README.md"),
71
  examples=[
72
  [
73
- parse_test_cases(test_cases, feature_names, gradio_input_types)[0],
74
  "weighted"
75
  ],
 
 
 
 
76
  ],
77
  cache_examples=False
78
  )
 
8
  from pathlib import Path
9
 
10
  added_description = """
11
+ See the 🤗 Space showing off how to combine various metrics here:
12
  [MarioBarbeque/CombinedEvaluationMetrics](https://huggingface.co/spaces/MarioBarbeque/CombinedEvaluationMetrics)
13
 
14
  In the specific use case of the `F1Fixed` metric, one writes the following:\n
 
20
  f1.compute()
21
  ```\n
22
 
23
+ where the `average` parameter can be chosen to configure the way f1 scores across labels are averaged. Acceptable values include `[None, 'micro', 'macro', 'weighted']` (
24
  or `binary` if there exist only two labels). \n
25
  """
26
 
 
33
  gradio_input_types = infer_gradio_input_types(feature_types)
34
 
35
  local_path = Path(sys.path[0])
36
+ # configure these randomly using randint generator and feature names?
37
+ test_case_1 = [ {"predictions":[1,2,3,4,5], "references":[1,2,5,4,3]} ]
38
+ test_case_2 = [ {"predictions":[9,8,7,6,5], "references":[7,8,9,6,5]} ]
39
 
40
  # configure this based on the input type, etc. for launch_gradio_widget
41
  def compute(input_df: pd.DataFrame, method: str):
 
72
  article=parse_readme(local_path / "README.md"),
73
  examples=[
74
  [
75
+ parse_test_cases(test_case_1, feature_names, gradio_input_types)[0], # notice how we unpack this for when we fix launch_gradio_widget
76
  "weighted"
77
  ],
78
+ [
79
+ parse_test_cases(test_case_2, feature_names, gradio_input_types)[0],
80
+ "micro"
81
+ ],
82
  ],
83
  cache_examples=False
84
  )