3
votes

I am working on a recommendation system that is using formal concept analysis to find the nearest similar client in a network. To create the formal concepts I am using pandas, for the networks networkx and for plotting matplotlib ie everything in Python 3.

My problem is that I want to represent on a graph the 2 types of attributes that have each node : names of clients and movies for instance. To give a quick example : node 1 : "names" -> ["Bob","John"] ; "movies" -> ["Jaws"]. The "names" and "movies" are coded as attributes to nodes. To continue the example :

G=nx.Graph()
G.add_nodes_from([1,2])
G.add_edge(1,2)    
G.node[1]['names']=["Bob","John"]
G.node[1]['movies']=["Jaws"]

Unfortunately, after long hours to search how to put 2 types of label on each node of the graph, I didn't find the answer. Here is what I think I should use but I don't know how to interact with matplotlib or networkx to do the double labelling :

node_labels = nx.get_node_attributes(G,"names")
node_labels2 = nx.get_node_attributes(G,"movies")
nx.draw_networkx_labels(G,labels = ?)

Another important aspect of the problem is to put the "movies" on top of the node, and the "names" under the node as shown in the image below.

An image of the type of graph I am looking for

Thank you a lot for your help !

1

1 Answers

0
votes

So in your network what does a node represent and what does an edge represent? Does each node represent a user and each edge similar taste between two users? I think you should clarify that because from your question it seems you have not.