Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
# import random
#
# import data_generator as dg
# import pandas as pd
# import math
import random
import matplotlib
import interaction_distance as id
# import re
import matplotlib.pyplot as plt
font = {'family' : 'normal',
'weight' : 'bold',
'size' : 22}
matplotlib.rc('font', **font)
# import main
# import ID_sm as idsm
# from correlation_measures.binning import Binning
import numpy as np
# import fractal_interaction_distance as fr
import merging as m
yvalue = []
bpsvalue = []
min_inbc = 20
max_inbc = 81
for init_bins_count in range(min_inbc, max_inbc, 20):
yv = []
bps = []
# for bp in [int(i * init_bins_count / 100) for i in range(70, 76)]:
for i in range(20, 90, 20):
bp = int(i * init_bins_count / 100)
# bp = int(0.7 * init_bins_count)
bin_width = int(init_bins_count / (bp + 1))
full_bins = init_bins_count - bin_width * (bp + 1)
# IDs = [0 for i in range(1, init_bins_count)]
#
# for i in range(bp + 1):
# IDs.extend([0]*((1 if i < full_bins else 0) + bin_width - 1) + [1])
# IDs = np.array(IDs[:-1])
bp_ids = [i for i in range(1, init_bins_count)]
random.shuffle(bp_ids)
bp_ids = bp_ids[:bp]
IDs = np.array([1 if i in bp_ids else 0 for i in range(1, init_bins_count)])
ID_threshold = id.compute_ID_threshold(IDs, 0.3)
F, discretizations = m.dynamic_merging(ID_threshold, IDs, init_bins_count)
bin = np.argmin(F[-1])
print('init_bins_count:', init_bins_count, ', ibp:', bp, ', bp:', bin)
bps.append(i)
yv.append(bin)
plt.plot([i for i in range(20, 90, 20)], yv, label=str(init_bins_count) + " bins")
# diff.append(F[-1][1] - F[-1][0])
yvalue.append(yv)
bpsvalue.append(bps)
plt.xlabel("% of break points")
plt.ylabel("Number of found bins")
plt.legend()
plt.show()
# init_bins_count = 100
# IDs = np.array([0 for i in range(int(init_bins_count / 2))] + [1] + [0 for i in range(init_bins_count - int(init_bins_count / 2) - 1)])
# ID_threshold = id.compute_ID_threshold(None, IDs, id.IDThresholdStrategy.AVG)
# F, discretizations = m.dynamic_merging(ID_threshold, IDs, init_bins_count)
# print(np.argmin(F[-1]))