jogonba2 commited on
Commit
3002aa2
·
1 Parent(s): 7c8640b

add examples

Browse files
Files changed (3) hide show
  1. app.py +1 -1
  2. clustering_evaluator.py +2 -2
  3. gradio_tst.py +10 -3
app.py CHANGED
@@ -2,4 +2,4 @@ import evaluate
2
  from gradio_tst import launch_gradio_widget2
3
 
4
  module = evaluate.load("clustering_evaluator.py")
5
- launch_gradio_widget2(module)
 
2
  from gradio_tst import launch_gradio_widget2
3
 
4
  module = evaluate.load("clustering_evaluator.py")
5
+ launch_gradio_widget2(module)
clustering_evaluator.py CHANGED
@@ -38,8 +38,8 @@ However, it allows to compute additional metrics when truth labels are passed to
38
  _KWARGS_DESCRIPTION = """
39
  Computes the quality of clustering results.
40
  Args:
41
- samples' vector representations
42
- predictions: computed cluster labels
43
  truth_labels (optional): truth labels to compute additional metrics
44
  Returns:
45
  silhouete_score
 
38
  _KWARGS_DESCRIPTION = """
39
  Computes the quality of clustering results.
40
  Args:
41
+ samples: vector representations
42
+ predictions: predicted cluster labels
43
  truth_labels (optional): truth labels to compute additional metrics
44
  Returns:
45
  silhouete_score
gradio_tst.py CHANGED
@@ -117,6 +117,12 @@ def launch_gradio_widget2(metric):
117
  def compute(data):
118
  return metric.compute(**parse_gradio_data(data, gradio_input_types))
119
 
 
 
 
 
 
 
120
  iface = gr.Interface(
121
  fn=compute,
122
  inputs=gr.Dataframe(
@@ -133,8 +139,9 @@ def launch_gradio_widget2(metric):
133
  ),
134
  title=f"Metric: {metric.name}",
135
  article=parse_readme(local_path / "README.md"),
136
- # TODO: load test cases and use them to populate examples
137
- # examples=[parse_test_cases(test_cases, feature_names, gradio_input_types)]
 
138
  )
139
 
140
- iface.launch(share=True)
 
117
  def compute(data):
118
  return metric.compute(**parse_gradio_data(data, gradio_input_types))
119
 
120
+ test_cases = [
121
+ {
122
+ "samples": [[0.1, 0.2, 0.3], [0.7, 0.6, 0.9], [0.8, 0.95, 0.85]],
123
+ "predictions": [0, 1, 1],
124
+ }
125
+ ]
126
  iface = gr.Interface(
127
  fn=compute,
128
  inputs=gr.Dataframe(
 
139
  ),
140
  title=f"Metric: {metric.name}",
141
  article=parse_readme(local_path / "README.md"),
142
+ examples=[
143
+ parse_test_cases(test_cases, feature_names, gradio_input_types)
144
+ ],
145
  )
146
 
147
+ iface.launch(share=True)