-
Notifications
You must be signed in to change notification settings - Fork 0
/
Plot_positions.py
116 lines (73 loc) · 3 KB
/
Plot_positions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/usr/bin/env python
# coding: utf-8
################################################################
# This script runs the algorithm and saves the recomended nodal coordinates.
################################################################
import Base_functions
import torch
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker
import numpy as np
import random as random
import numpy.linalg as np_math
import networkx as nx
import sklearn
from sklearn.linear_model import LogisticRegression
import seaborn as sns
import seaborn as sns
import pandas as pd
import statsmodels.api as sm
from scipy import stats
from scipy.special import expit, logit
import sys
import os
# In[ ]:
itera = 1
data = pd.read_csv('plotting_data_AddH.csv')
for i in range(data.shape[0]):
print(i/data.shape[0])
p_in_i = round(float(data.loc[i, 'p_increase']), 4)
p_out_i = round(float(data.loc[i, 'p_out']), 4)
num_groups = int(data.loc[i, 'num_groups'])
total_nodes = int(data.loc[i, 'total_nodes'])
cat_cont = int(data.loc[i, 'cc'])
gamma = round(float(data.loc[i, 'gamma']), 4)
# In[3]:
# In[5]:
G, X, B_true = Base_functions.Data_generator(num_groups = num_groups,
p_in_i = p_in_i, p_out_i = p_out_i, total_nodes = total_nodes, cat_cont = cat_cont)
# In[6]:
G, res, X_colors, node_dis, B, Q, positions = Base_functions.Vertex_Positions(G = G, step_size = 0.1, thresh = 0.000001, X = X,
gamma = gamma, B_true = B_true, cat_cont = cat_cont)
# In[9]:
print(positions)
np.savetxt(str("Nodal_Covariates" +
"_IT_" + str(itera) +
"_TN_" + str(total_nodes) +
"_NG_" + str(num_groups) +
"_PI_" + str(p_in_i) +
"_PO_" + str(p_out_i) +
"_CC_" + str(cat_cont) +
"_Gamma_" + str(gamma) +
".csv"), np.insert(X, 0, G.nodes(), axis=1), delimiter=',', comments='') # Inserts Node names in first column
np.savetxt(str("Nodal_Positions" +
"_IT_" + str(itera) +
"_TN_" + str(total_nodes) +
"_NG_" + str(num_groups) +
"_PI_" + str(p_in_i) +
"_PO_" + str(p_out_i) +
"_CC_" + str(cat_cont) +
"_Gamma_" + str(gamma) +
".csv"), np.insert(positions, 0, G.nodes(), axis=1), delimiter=',', comments='')
nx.write_edgelist(G, str("Edge_List" +
"_IT_" + str(itera) +
"_TN_" + str(total_nodes) +
"_NG_" + str(num_groups) +
"_PI_" + str(p_in_i) +
"_PO_" + str(p_out_i) +
"_CC_" + str(cat_cont) +
"_Gamma_" + str(gamma) +
".csv"), delimiter=",", data=False)
# In[ ]:
# In[ ]:
# In[2]: