overall probability of connection for any two nodes'''

from graspy.models import EREstimator
er = EREstimator(directed=True, loops=False)  # Create Erdos-Reyni estimator
er.fit(adj)  # Fit Erdos-Reyni model

# Show results
fig, ax = plt.subplots(1, 2)
plotHeatmap(er.p_mat_,
            "ER probability matrix",
            params={
                'vmin': 0,
                'vmax': 1,
                'ax': ax[0]
            })
plotHeatmap(er.sample()[0], "ER sample", params={'ax': ax[1]})
fig.suptitle('Erdos-Reyni (ER) model', fontsize=16)
print(f"ER \"p\" parameter: {er.p_}")
plt.savefig('figure.png')

# ---------------------------------------
# Degree-corrected Erdos-Reyni (DCER) model
# ---------------------------------------
'''A slightly more complicated variant of the ER model is the degree-corrected
Erdos-Reyni model (DCER). Here, there is still a global parameter 𝑝 to specify
relative connection probability between all edges. However, we add a promiscuity
parameter πœƒπ‘– for each node 𝑖 which specifies its expected degree relative to other
nodes: 𝑃𝑖𝑗=πœƒπ‘–πœƒπ‘—π‘, so the probility of an edge from 𝑖 to 𝑗 is a function of the two nodes'
degree-correction parameters, and the overall probability of an edge in the graph'''

from graspy.models import DCEREstimator
Esempio n. 2
0
plt.savefig("DrosophilaRightMB", bbox_inches='tight')

er = EREstimator(directed=True,loops=False)
er.fit(adj)
print(f"ER \"p\" parameter: {er.p_}")
heatmap(er.p_mat_,
        inner_hier_labels=labels,
        font_scale=1.5,
        title="ER probability matrix",
        vmin=0, vmax=1,
        sort_nodes=True)

plt.savefig("ERProbabilityMatrix", bbox_inches='tight')

heatmap(er.sample()[0],
        inner_hier_labels=labels,
        font_scale=1.5,
        title="ER sample",
        sort_nodes=True);

plt.savefig("ERSample", bbox_inches='tight')

dcer = DCEREstimator(directed=True,loops=False)
dcer.fit(adj)
print(f"DCER \"p\" parameter: {dcer.p_}")
heatmap(dcer.p_mat_,
        inner_hier_labels=labels,
        vmin=0,
        vmax=1,
        font_scale=1.5,