Update app.py
Browse files
app.py
CHANGED
@@ -1,17 +1,15 @@
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
import pandas as pd
|
3 |
from io import StringIO
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
# Call the select_top_n_papers method
|
13 |
-
selected_paper_info = oc.select_top_n_papers(n, positive_csv_file, unlabelled_csv_file, Hyperparameter_nu)
|
14 |
-
|
15 |
# Create a StringIO object to store CSV data
|
16 |
csv_buffer = StringIO()
|
17 |
|
@@ -28,20 +26,10 @@ def predict_and_download(positive_csv_file, unlabelled_csv_file, n, Hyperparamet
|
|
28 |
# Create the interface
|
29 |
iface = gr.Interface(
|
30 |
fn=predict_and_download,
|
31 |
-
inputs=[
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
gr.inputs.Number(label="Hyperparameter nu", default=0.5)
|
36 |
-
],
|
37 |
-
outputs=[
|
38 |
-
gr.outputs.Dataframe(label="Selected Papers", formats=["csv", "json"]),
|
39 |
-
gr.outputs.DownloadButton(label="Download CSV")
|
40 |
-
],
|
41 |
-
title="Paper Prediction",
|
42 |
-
description="Enter the number of papers to select and upload CSV files for labelled and unlabelled data.",
|
43 |
-
article="This interface uses the OneClass algorithm to select the top N papers based on the input CSV files. The Hyperparameter nu controls the sensitivity of the algorithm.",
|
44 |
-
theme="default",
|
45 |
allow_flagging='never' # Disable flagging feature
|
46 |
)
|
47 |
|
|
|
1 |
+
import oneclass
|
2 |
+
import Cosine_distance
|
3 |
import gradio as gr
|
4 |
import pandas as pd
|
5 |
from io import StringIO
|
6 |
|
7 |
+
def predict_and_download(classifier_oneclass_or_Cosine_distance ,positive_csv_file, unlabelled_csv_file, n,Hyperparameter_nu):
|
8 |
+
if choice == "oneclass" :
|
9 |
+
selected_paper_info = oneclass.select_top_n_papers(n, positive_csv_file, unlabelled_csv_file,Hyperparameter_nu)
|
10 |
+
else :
|
11 |
+
selected_paper_info = Cosine_distance.recommend_papers(positive_csv_file, positive_csv_file, n)
|
12 |
+
|
|
|
|
|
|
|
|
|
13 |
# Create a StringIO object to store CSV data
|
14 |
csv_buffer = StringIO()
|
15 |
|
|
|
26 |
# Create the interface
|
27 |
iface = gr.Interface(
|
28 |
fn=predict_and_download,
|
29 |
+
inputs=["text","file", "file", "number","number"],
|
30 |
+
outputs=[gr.DataFrame(label="Recommended Papers"), gr.DownloadButton(label="Download CSV")],
|
31 |
+
title="Personalized Arxiv Feed",
|
32 |
+
description="Enter text and upload CSV files for labelled and unlabelled data.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
allow_flagging='never' # Disable flagging feature
|
34 |
)
|
35 |
|