#print(mat_kend)
#Граф Кенделла
mat_1_03=mat_kend.copy(deep=True)
for c in range(len(a[1])):
for b in range(len(a[1])):
if mat_kend[c][b]>0.9:
mat_1_03[c][b]=1
G2.add_edge(c,b)
else:
mat_1_03[c][b]=0
from networkx.algorithms.approximation import clique
K_cliq=(clique.max_clique(G2))
#print(mat_1_03)
#Сравнение корреляций
#print(mat_stirl,mat_kend
rez=1-abs((len(S_cliq)-len(K_cliq))/(max(len(S_cliq),len(K_cliq))))
print(rez)
return(rez)
opt_list=[]
for j in range(4):
for i in range(100):
opt_list.append(testscore)
testscore=corOPTIMIZE(i+2,0.65+(j/10))
print(testscore,0.65+(j/10))
print(opt_list)
my_file = open("xyy.txt", "w")
my_file.write(str(opt_list))
my_file.close()
for j in range(4):
koef=j/10+0.6
print (koef)
opt_list_part=[]
for i in range(100):
opt_list_part.append(opt_list[i][0])
dataxx=opt_list_part
#dataxx = pd.read_csv("listfile3.txt", sep=",", header=None)
sorted(dataxx)
n_binst=1000
print(opt_list_part)
histogram(dataxx, 25, cumulative=False, x_label = "", y_label = "", title = "")
koef=0.95
rezult=[]
for i in range(5000):
x=cortest_Cliq(i+1,koef)
rezult.append(x)
with open('listfile.txt', 'w') as filehandle:
for listitem in rezult:
filehandle.write('%s\n' % listitem)
for j in range(4):
koef=j/10+0.65
rezult=[]
for i in range(10000):
x=cortest(i+1,koef)
rezult.append(x)
with open('listfile'+str(j)+'.txt', 'w') as filehandle:
for listitem in rezult:
filehandle.write('%s\n' % listitem)
with open('listfile.txt', 'w') as filehandle:
for listitem in rezult:
filehandle.write('%s\n' % listitem)
#dataxx=test3
dataxx = pd.read_csv("listfile3.txt", sep=",", header=None)
sorted(dataxx)
n_binst=1000
def histogram(data, n_bins, cumulative=False, x_label = "", y_label = "", title = ""):
_, ax = plt.subplots()
ax.hist(data, bins = n_bins, cumulative = cumulative, color = '#539caf')
ax.set_ylabel(y_label)
ax.set_xlabel(x_label)
ax.set_title(title)
print(dataxx)
histogram(dataxx, 1000, cumulative=False, x_label = "", y_label = "", title = "Корреляция Спирмана= 0.95||Корреляция Кендэла=0.8")
def lineplot(x_data, y_data, x_label="", y_label="", title=""):
# Create the plot object
_, ax = plt.subplots()
# Plot the best fit line, set the linewidth (lw), color and
# transparency (alpha) of the line
ax.plot(x_data, y_data, lw = 2, color = '#539caf', alpha = 1)
# Label the axes and provide a title
ax.set_title(title)
ax.set_xlabel(x_label)
ax.set_ylabel(y_label)
lineplot(range(100),test3)
for i in range(4):
test,test2,test3=corFIND_OPT_Cliq(2,0.65+i/10)
title_S="Схожесть графов при корреляции Спирмена"+(str(i/10+0.65))
lineplot(range(100),test3,x_label="Порог Кендэла", y_label="Коэффициент схожести графов", title=title_S)
def scatterplot(x_data, y_data, x_label="", y_label="", title="", color = "r", yscale_log=False):
# Create the plot object
_, ax = plt.subplots()
# Plot the data, set the size (s), color and transparency (alpha)
# of the points
ax.scatter(x_data, y_data, s = 10, color = color, alpha = 0.75)
if yscale_log == True:
ax.set_yscale('log')
# Label the axes and provide a title
ax.set_title(title)
ax.set_xlabel(x_label)
ax.set_ylabel(y_label)
dataxx=[]
dataxy=[]
for i in range(100):
dataxx.append(opt_list[i][0])
dataxy.append(opt_list[i][1])
#dataxx = pd.read_csv("listfile3.txt", sep=",", header=None)
n_binst=1000
x_data=dataxx
y_data=dataxy
scatterplot(x_data, y_data, x_label="Схожесть", y_label="Порог Кендэла", title="Корреляция Спирмена=0.65", color = "r", yscale_log=False)
dataxx = pd.read_csv("listfile3.txt", sep=",", header=None)
sorted(dataxx[0])
n_binst=1000
def histogram(data, n_bins, cumulative=False, x_label = "", y_label = "", title = ""):
_, ax = plt.subplots()
ax.hist(data, bins = n_bins, cumulative = cumulative, color = '#539caf')
ax.set_ylabel(y_label)
ax.set_xlabel(x_label)
ax.set_title(title)
histogram(dataxx[0], 500, cumulative=False, x_label = "Коэффицент близости графов", y_label = "Частота", title = "Корреляция Спирмана= 0.65||Корреляция Кендэла=0.465")