Python Network Graph

Python Day 1:

Neuron Network Graph

Suppose we would like to build a basic network graph implies a student’s grade is affected by IQ and Study. In addition, Interest and method affect the result of the study.

# libraries
import pandas as pd
import numpy as np
import networkx as nx
import matplotlib.pyplot as plt
#build dataframe with connections:
df = pd.DataFrame({ 'from':['Grade', 'Study', "Interest", "Method", 'Grade'], 'to':['IQ', 'Grade',"Study", "Study", 'Study']})
# Build your graph
G=nx.from_pandas_dataframe(df, 'from', 'to')
# Plot it
nx.draw(G, with_labels=True)
       from     to
0     Grade     IQ
1     Study  Grade
2  Interest  Study
3    Method  Study
4     Grade  Study


inspired by

Happy Studying ❤!


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Social media & sharing icons powered by UltimatelySocial
%d bloggers like this: