Spaces:
Sleeping
Sleeping
Commit
·
80c53ff
1
Parent(s):
dbdc0fc
Update app.py
Browse files
app.py
CHANGED
@@ -1,8 +1,11 @@
|
|
1 |
import gradio as gr
|
2 |
from Recommender import Recommender
|
3 |
from Preprocess import ModelUtils, Preprocess
|
|
|
|
|
4 |
|
5 |
-
|
|
|
6 |
model_path = "model_root"
|
7 |
|
8 |
data = pd.read_csv(data_path)
|
@@ -14,16 +17,17 @@ p = Preprocess(model_path)
|
|
14 |
|
15 |
data = pd.read_csv(data_path)
|
16 |
|
17 |
-
rec = Recommender (
|
18 |
k = 3
|
19 |
|
20 |
table = [tuple(row) for row in data.to_numpy()]
|
21 |
|
22 |
def recom (title) :
|
23 |
-
rec.recommend_k(table, k, title)
|
|
|
|
|
24 |
|
25 |
demo = gr.Interface(fn=recom,
|
26 |
-
inputs=[gr.Dropdown(choices = list(
|
27 |
-
|
28 |
-
outputs=gr.Textbox(label="Recommended"))
|
29 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from Recommender import Recommender
|
3 |
from Preprocess import ModelUtils, Preprocess
|
4 |
+
import numpy as np
|
5 |
+
import pandas as pd
|
6 |
|
7 |
+
|
8 |
+
data_path = "result.csv"
|
9 |
model_path = "model_root"
|
10 |
|
11 |
data = pd.read_csv(data_path)
|
|
|
17 |
|
18 |
data = pd.read_csv(data_path)
|
19 |
|
20 |
+
rec = Recommender (0, 1, 2, 3, 4)
|
21 |
k = 3
|
22 |
|
23 |
table = [tuple(row) for row in data.to_numpy()]
|
24 |
|
25 |
def recom (title) :
|
26 |
+
indices, scores, title_scores = rec.recommend_k(table, k, title)
|
27 |
+
out = list(data[indices]['title'])
|
28 |
+
return "\n".join(out)
|
29 |
|
30 |
demo = gr.Interface(fn=recom,
|
31 |
+
inputs=[gr.Dropdown(choices = list(data['title'][:20]), multiselect=False, label="Titles")],
|
32 |
+
outputs=gr.Textbox(label="Titles of recommended items"), type='multiline')
|
|
|
33 |
demo.launch()
|