Spaces:
Sleeping
Sleeping
John Graham Reynolds
commited on
Commit
·
728d57c
1
Parent(s):
3a45cce
change input tuple to input list
Browse files
app.py
CHANGED
|
@@ -19,19 +19,16 @@ local_path = Path(sys.path[0])
|
|
| 19 |
test_cases = [ {"predictions":[1,2,3,4,5], "references":[1,2,5,4,3]} ] # configure this randomly using randint generator and feature names?
|
| 20 |
|
| 21 |
# configure this based on the input type, etc. for launch_gradio_widget
|
| 22 |
-
|
| 23 |
|
| 24 |
-
|
| 25 |
-
|
| 26 |
|
| 27 |
-
|
| 28 |
|
| 29 |
-
|
| 30 |
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
def compute():
|
| 34 |
-
pass
|
| 35 |
|
| 36 |
space = gr.Interface(
|
| 37 |
fn=compute,
|
|
@@ -42,7 +39,7 @@ space = gr.Interface(
|
|
| 42 |
row_count=5,
|
| 43 |
datatype=json_to_string_type(gradio_input_types),
|
| 44 |
),
|
| 45 |
-
feature_names
|
| 46 |
],
|
| 47 |
outputs=gr.Textbox(label=metric.name),
|
| 48 |
description=(
|
|
|
|
| 19 |
test_cases = [ {"predictions":[1,2,3,4,5], "references":[1,2,5,4,3]} ] # configure this randomly using randint generator and feature names?
|
| 20 |
|
| 21 |
# configure this based on the input type, etc. for launch_gradio_widget
|
| 22 |
+
def compute(input_df: pd.DataFrame, feature_names: list[str]):
|
| 23 |
|
| 24 |
+
predicted = [int(num) for num in input_df[feature_names[0]].to_list()]
|
| 25 |
+
references = [int(num) for num in input_df[feature_names[1]].to_list()]
|
| 26 |
|
| 27 |
+
metric.add_batch(predictions=predicted, references=references)
|
| 28 |
|
| 29 |
+
outputs = metric._compute()
|
| 30 |
|
| 31 |
+
f"Your metrics are as follows: \n {outputs}"
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
space = gr.Interface(
|
| 34 |
fn=compute,
|
|
|
|
| 39 |
row_count=5,
|
| 40 |
datatype=json_to_string_type(gradio_input_types),
|
| 41 |
),
|
| 42 |
+
list(feature_names)
|
| 43 |
],
|
| 44 |
outputs=gr.Textbox(label=metric.name),
|
| 45 |
description=(
|