Spaces:
Sleeping
Sleeping
abdullahmeda
commited on
Commit
•
fe845ab
1
Parent(s):
2bb0b0b
cw2.py
CHANGED
@@ -123,29 +123,26 @@ def also_like(data, doc_uuid, visitor_uuid, ascending, req_5=True):
|
|
123 |
|
124 |
# Req 6
|
125 |
def also_like_graph(data, doc_uuid, visitor_uuid, ascending):
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
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]))
|
|
|
123 |
|
124 |
# Req 6
|
125 |
def also_like_graph(data, doc_uuid, visitor_uuid, ascending):
|
126 |
+
top_docs = also_like(data, doc_uuid, visitor_uuid, ascending, req_5=False)
|
127 |
+
y = top_docs[1].value_counts()
|
128 |
+
y = pd.DataFrame(y)
|
129 |
+
y.loc[len(y.index)] = [visitor_uuid, doc_uuid]
|
130 |
+
print(y)
|
131 |
+
dot = graphviz.Digraph()
|
132 |
+
for index, row in top_docs.iterrows():
|
133 |
+
# if(index <= 7):
|
134 |
+
# print(row[0], row[1])
|
135 |
+
dot.node(str(row[0]), str(row[0])[-4:])
|
136 |
+
dot.node(str(row[1]), str(row[1])[-4:])
|
137 |
+
dot.edge(str(row[0]), str(row[1]))
|
138 |
+
|
139 |
+
# print(dot.source)
|
140 |
+
|
141 |
+
dot.render('output.dot').replace('\\', '/')
|
142 |
+
|
143 |
+
(graph,) = pydot.graph_from_dot_file('output.dot')
|
144 |
+
graph.write_png('output.png')
|
145 |
+
return 'output.png'
|
|
|
|
|
|
|
146 |
|
147 |
|
148 |
# print(also_like(data_tiny, "100713205147-2ee05a98f1794324952eea5ca678c026", "b5d13a36dad1147b", False).groupby(1).count().nlargest(10, [0]))
|