Spaces:
Sleeping
Sleeping
Commit
·
26aab38
1
Parent(s):
85a89aa
- app.py +6 -5
- cw2.py +2 -1
- output.png → output_test.png +0 -0
app.py
CHANGED
@@ -24,8 +24,9 @@ def req_4(data):
|
|
24 |
plot_avid_readers(globals()[f"data_{data}"])
|
25 |
|
26 |
|
27 |
-
def
|
28 |
-
return also_like(globals()[f"data_{data}"], doc, vis, sort == "Ascending")
|
|
|
29 |
|
30 |
|
31 |
with gr.Blocks(css="""
|
@@ -124,13 +125,13 @@ with gr.Blocks(css="""
|
|
124 |
also_likes_df = gr.Dataframe(value=also_like(globals()[f"data_{selected_dataset_5.value}"], t5_doc_uuid.value, t5_visitor_uuid.value,
|
125 |
t5_sorting.value == 'Ascending'))
|
126 |
|
127 |
-
req_5_submit.click(fn=req_5, inputs=[t5_doc_uuid, t5_visitor_uuid, t5_sorting, selected_dataset_5], outputs=[also_likes_df])
|
128 |
-
|
129 |
gr.Markdown("""
|
130 |
## Requirement 6: "Also likes" graph
|
131 |
|
132 |
For the above “also like” functionality, this section generates a graph that displays the relationship between the input document and all documents that have been found as “also like” documents (and only these documents)
|
133 |
""")
|
134 |
-
gr.Image('output.png')
|
|
|
|
|
135 |
|
136 |
demo.launch()
|
|
|
24 |
plot_avid_readers(globals()[f"data_{data}"])
|
25 |
|
26 |
|
27 |
+
def req_5_and_6(doc, vis, sort, data):
|
28 |
+
return also_like(globals()[f"data_{data}"], doc, vis, sort == "Ascending"), \
|
29 |
+
also_like_graph(globals()[f"data_{data}"], doc, vis, sort == "Ascending")
|
30 |
|
31 |
|
32 |
with gr.Blocks(css="""
|
|
|
125 |
also_likes_df = gr.Dataframe(value=also_like(globals()[f"data_{selected_dataset_5.value}"], t5_doc_uuid.value, t5_visitor_uuid.value,
|
126 |
t5_sorting.value == 'Ascending'))
|
127 |
|
|
|
|
|
128 |
gr.Markdown("""
|
129 |
## Requirement 6: "Also likes" graph
|
130 |
|
131 |
For the above “also like” functionality, this section generates a graph that displays the relationship between the input document and all documents that have been found as “also like” documents (and only these documents)
|
132 |
""")
|
133 |
+
also_likes_graph = gr.Image('output.png')
|
134 |
+
|
135 |
+
req_5_submit.click(fn=req_5_and_6, inputs=[t5_doc_uuid, t5_visitor_uuid, t5_sorting, selected_dataset_5], outputs=[also_likes_df, also_likes_graph])
|
136 |
|
137 |
demo.launch()
|
cw2.py
CHANGED
@@ -127,6 +127,7 @@ def also_like_graph(data, doc_uuid, visitor_uuid, ascending):
|
|
127 |
top_docs = also_like(data, doc_uuid, visitor_uuid, ascending, req_5=False)
|
128 |
y = top_docs[1].value_counts()
|
129 |
y = pd.DataFrame(y)
|
|
|
130 |
print(y)
|
131 |
dot = graphviz.Digraph()
|
132 |
for index, row in top_docs.iterrows():
|
@@ -144,7 +145,7 @@ def also_like_graph(data, doc_uuid, visitor_uuid, ascending):
|
|
144 |
graph.write_png('output.png')
|
145 |
return 'output.png'
|
146 |
except:
|
147 |
-
return "
|
148 |
|
149 |
|
150 |
# print(also_like(data_tiny, "100713205147-2ee05a98f1794324952eea5ca678c026", "b5d13a36dad1147b", False).groupby(1).count().nlargest(10, [0]))
|
|
|
127 |
top_docs = also_like(data, doc_uuid, visitor_uuid, ascending, req_5=False)
|
128 |
y = top_docs[1].value_counts()
|
129 |
y = pd.DataFrame(y)
|
130 |
+
y.loc[len(y.index)] = [visitor_uuid, doc_uuid]
|
131 |
print(y)
|
132 |
dot = graphviz.Digraph()
|
133 |
for index, row in top_docs.iterrows():
|
|
|
145 |
graph.write_png('output.png')
|
146 |
return 'output.png'
|
147 |
except:
|
148 |
+
return "output_test.jpg"
|
149 |
|
150 |
|
151 |
# print(also_like(data_tiny, "100713205147-2ee05a98f1794324952eea5ca678c026", "b5d13a36dad1147b", False).groupby(1).count().nlargest(10, [0]))
|
output.png → output_test.png
RENAMED
File without changes
|