Exemple #1
0
	def plot_random(self, dataDir, plotDir, files):
		output = plotDir
		pyf = PyFunctions()
		for x in range(len(files)):
			path = dataDir + files[x]
			try:
				f = open(path, 'r')
			except Exception, e:
				continue
			l = [map(float, line.split()) for line in f]
			if files[x] == 'cmp_NoCountermeasure.txt':
				label = "No countermeasure"
				marker = '.'
			elif files[x] == 'cmp_AdditiveNoise.txt':
				label = "Additive noise"
				marker = "*"
			elif files[x] == 'cmp_Transfiguration.txt':
				label = "Transfiguration"
				marker = "o"
			elif files[x] == 'cmp_KAnonymity.txt':
				label = "K anonymity"
				marker = "^"
			elif files[x] == 'cmp_KClustering.txt':
				label = "K clustering"
				marker = "D"
			plt.plot(l[0], pyf.normalize(pyf.average(l[1:])), label = label, marker = marker)
Exemple #2
0
 def plot(self, dataDir, plotDir, files):
     output = plotDir
     pyf = PyFunctions()
     for x in range(len(files)):
         path = dataDir + files[x]
         try:
             f = open(path, 'r')
         except Exception, e:
             continue
         l = [map(float, line.split()) for line in f]
         if files[x] == 'traddOff_KAnonymity.txt':
             title = "Trade-off bar of k anonymity"
         elif files[x] == 'traddOff_KClustering.txt':
             title = "Trade-off bar of k clustering"
         plt.figure()
         plt.bar([k - 0.25 for k in l[0]],
                 pyf.normalize(l[1]),
                 0.5,
                 color='g')
         plt.xticks(map(int, l[0]))
         plt.yticks([0.1 * i for i in range(1, 12)])
         plt.title(title)
         plt.xlabel('k')
         plt.ylabel('IC')
         plt.tight_layout()
         # plt.show()
         plt.savefig(output + files[x].replace('txt', 'png'))
Exemple #3
0
 def plot(self, dataDir, plotDir, files):
     n = len(files)  # number of bar pairs needed
     cmName = {
         'NoCountermeasure': 'No countermeasure',
         'AdditiveNoise': 'Additive noise',
         'Transfiguration': 'Transfiguration',
         'KAnonymity': 'K Anonymity',
         'KClustering': 'K Clustering'
     }
     width = 0.35
     pyf = PyFunctions()
     ic_random = []  # hold ic value of random queries
     ic_smart = []  # hold ic value of smart queries
     ctm = []
     for x in range(len(files)):
         try:
             path = dataDir + 'cmp_' + files[x] + '.txt'
             f = open(path, 'r')
             l = [map(float, line.split()) for line in f]
             avgl = pyf.average(l[1:])
             ic_random.append(avgl[len(avgl) - 1])
             path = dataDir + 'cmp_smart_' + files[x] + '.txt'
             f = open(path, 'r')
             l = [map(float, line.split()) for line in f]
             avgl = pyf.average(l[1:])
             ic_smart.append(avgl[len(avgl) - 1])
             ctm.append(cmName[files[x]])
         except Exception, e:
             continue
Exemple #4
0
 def plot_random(self, dataDir, plotDir, files):
     output = plotDir
     pyf = PyFunctions()
     for x in range(len(files)):
         path = dataDir + files[x]
         try:
             f = open(path, 'r')
         except Exception, e:
             continue
         l = [map(float, line.split()) for line in f]
         if files[x] == 'cmp_NoCountermeasure.txt':
             label = "No countermeasure"
             marker = '.'
         elif files[x] == 'cmp_AdditiveNoise.txt':
             label = "Additive noise"
             marker = "*"
         elif files[x] == 'cmp_Transfiguration.txt':
             label = "Transfiguration"
             marker = "o"
         elif files[x] == 'cmp_KAnonymity.txt':
             label = "K anonymity"
             marker = "^"
         elif files[x] == 'cmp_KClustering.txt':
             label = "K clustering"
             marker = "D"
         plt.plot(l[0],
                  pyf.normalize(pyf.average(l[1:])),
                  label=label,
                  marker=marker)
Exemple #5
0
	def plot(self, dataDir, plotDir, files):
		output = plotDir
		pyf = PyFunctions()
		for x in range(len(files)):
			path = dataDir + files[x]
			try:
				f = open(path, 'r')
			except Exception, e:
				continue
			plt.figure()
			l = [map(float, line.split()) for line in f]
			if files[x] == 'traddOff_smart_AdditiveNoise.txt':
				title = "Trade-off curve of additive noise with smart queries"
				xlabel = 'Noise level'
			elif files[x] == 'traddOff_smart_Transfiguration.txt':
				title = "Trade-off curve of transfiguration with smart queries"
				xlabel = 'Number of sides'
				plt.xticks(map(int, l[0]))
			plt.plot(l[0], pyf.normalize(l[1]))
			plt.legend()
			plt.title(title)
			plt.xlabel(xlabel)
			plt.ylabel('IC')
			plt.tight_layout()
			plt.savefig(output + files[x].replace('txt', 'png'))
	def plot_random_smart(self, dataDir, plotDir, files):
		output = plotDir
		pyf = PyFunctions()
		for x in range(len(files)):
			path = dataDir + files[x]
			try:
				f = open(path, 'r')
			except Exception, e:
				continue
			l = [map(float, line.split()) for line in f]
			if files[x] == 'cmp_NoCountermeasure.txt':
				label = "Random queries"
				marker = '.'
			elif files[x] == 'cmp_smart_NoCountermeasure.txt':
				label = "Smart qeuries"
				marker = "*"
			plt.plot(l[0], pyf.normalize(pyf.average(l[1:])), label = label, marker = marker)
Exemple #7
0
 def plot_random_smart(self, dataDir, plotDir, files):
     output = plotDir
     pyf = PyFunctions()
     for x in range(len(files)):
         path = dataDir + files[x]
         try:
             f = open(path, 'r')
         except Exception, e:
             continue
         l = [map(float, line.split()) for line in f]
         if files[x] == 'cmp_NoCountermeasure.txt':
             label = "Random queries"
             marker = '.'
         elif files[x] == 'cmp_smart_NoCountermeasure.txt':
             label = "Smart qeuries"
             marker = "*"
         plt.plot(l[0],
                  pyf.normalize(pyf.average(l[1:])),
                  label=label,
                  marker=marker)
	def plot(self, dataDir, plotDir, files):
		output = plotDir
		pyf = PyFunctions()
		for x in range(len(files)):
			path = dataDir + files[x]
			try:
				f = open(path, 'r')
			except Exception, e:
				continue
			l = [map(float, line.split()) for line in f]
			if files[x] == 'traddOff_smart_KAnonymity.txt':
				title = "Trade-off bar of k anonymity with smart queries"
			elif files[x] == 'traddOff_smart_KClustering.txt':
				title = "Trade-off bar of k clustering with smart queries"
			plt.figure()
			plt.bar([k - 0.25 for k in l[0]], pyf.normalize(l[1]), 0.5, color = 'g')
			plt.xticks(map(int, l[0]))
			plt.yticks([0.1 * i for i in range(1, 12)])
			plt.title(title)
			plt.xlabel('k')
			plt.ylabel('IC')
			plt.tight_layout()
			# plt.show()
			plt.savefig(output + files[x].replace('txt', 'png'))
Exemple #9
0
	def plot(self, dataDir, plotDir, files):
		n = len(files) # number of bar pairs needed
		cmName = {'NoCountermeasure': 'No countermeasure', 'AdditiveNoise': 'Additive noise', 
			'Transfiguration': 'Transfiguration', 'KAnonymity': 'K Anonymity', 'KClustering': 'K Clustering'}
		width = 0.35
		pyf = PyFunctions()
		ic_random = []  # hold ic value of random queries
		ic_smart = []   # hold ic value of smart queries
		ctm = []
		for x in range(len(files)):	
			try:
				path = dataDir + 'cmp_' + files[x] + '.txt'
				f = open(path, 'r')
				l = [map(float, line.split()) for line in f]
				avgl = pyf.average(l[1:])
				ic_random.append(avgl[len(avgl) - 1])
				path = dataDir + 'cmp_smart_' + files[x] + '.txt'
				f = open(path, 'r')
				l = [map(float, line.split()) for line in f]
				avgl = pyf.average(l[1:])
				ic_smart.append(avgl[len(avgl) - 1])
				ctm.append(cmName[files[x]])
			except Exception, e:
				continue