abdullahmeda commited on
Commit
7a64d79
·
1 Parent(s): d8cd9b2
Files changed (1) hide show
  1. cw2.py +16 -12
cw2.py CHANGED
@@ -124,22 +124,26 @@ def also_like(data, doc_uuid, visitor_uuid, ascending, req_5=True):
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'
 
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
+ top_docs[0] = top_docs[0].str[-4:]
128
+ top_docs[1] = top_docs[1].str[-4:]
129
+ print(top_docs)
130
+ # y = top_docs[1].value_counts()
131
+ # y = pd.DataFrame(y)
132
  # y.loc[len(y.index)] = [visitor_uuid, doc_uuid]
133
+ # print(y)
134
  dot = graphviz.Digraph()
135
  for index, row in top_docs.iterrows():
136
+ dot.node(str(row[0]), str(row[1]))
137
+ # # if(index <= 7):
138
+ # # print(row[0], row[1])
139
+ # dot.node(str(row[0]), str(row[0])[-4:])
140
+ # dot.node(str(row[1]), str(row[1])[-4:])
141
+ # dot.edge(str(row[0]), str(row[1]))
142
+ #
143
+ # # print(dot.source)
144
+ #
145
  dot.render('output.dot').replace('\\', '/')
146
+ #
147
  (graph,) = pydot.graph_from_dot_file('output.dot')
148
  graph.write_png('output.png')
149
  return 'output.png'