Úvod do datové sady

Intermediate Network Analysis in Python

Eric Ma

Data Carpentry instructor and author of nxviz package

Úvod do datové sady a případové studie

  • Datová sada příspěvků z vysokoškolského fóra, 6 měsíců
  • Oddíly uzlů: studenti, fóra
  • Aktivity v kapitole:
    • Vytvoření grafu z pandas DataFrame
    • Výpočet unipartitních projekcí bipartitního grafu
    • Vizualizace
    • Filtrování a analýza časových řad
  • Shrnutí dříve použitých funkcí
Intermediate Network Analysis in Python

Grafy z DataFrame

df
   customers    products
0  customerA    product1
1  customerB    product2
...
G = nx.Graph()

G.add_nodes_from(df['products'], bipartite='products') G.add_nodes_from(df['customers'], bipartite='customers')
list(G.nodes())
['product1', 'customerC', 'product2', 'customerB', 'customerA']
list(G.edges())
[]
Intermediate Network Analysis in Python

Grafy z DataFrame

G.add_edges_from(zip(df['customers'], df['products']))

list(G.edges())
[('product1', 'customerC'), ('product1', 'customerA'), 
    ('customerC', 'product2'), ('product2', 'customerB')]
Intermediate Network Analysis in Python

Bipartitní projekce

cust_nodes = [n for n in G.nodes() if G.nodes[n]
                 ['bipartite'] == 'customers']

prod_nodes = [n for n in G.nodes() if G.nodes[n] ['bipartite'] == 'products']
prodG = nx.bipartite.projected_graph(G, nodes=prod_nodes) custG = nx.bipartite.projected_graph(G, nodes=cust_nodes)
list(prodG.nodes())
['product1', 'product2']
list(custG.nodes())
['customerC', 'customerB', 'customerA']
Intermediate Network Analysis in Python

Pojďme si procvičit!

Intermediate Network Analysis in Python

Preparing Video For Download...