diff --git a/DAS/visualizor.py b/DAS/visualizor.py index 1a850b9..cc66a2a 100644 --- a/DAS/visualizor.py +++ b/DAS/visualizor.py @@ -1070,6 +1070,7 @@ class Visualizor: plt.ylabel(conf['ylabel']) plt.title(conf['title']) plt.savefig(f"results/{self.execID}/heatmaps/{conf['path']}") + plt.clf() # x -> network degree, y -> number of nodes, weights -> simulation duration def plotNWDegVsNodeOnRuntime(self): @@ -1085,8 +1086,32 @@ class Visualizor: 'weights': weights, 'xlabel': 'Net Degree', 'ylabel': 'Number of Nodes', - 'title': 'Heatmap of Net Degree, Number of Nodes & Simulation Runtime', - 'path': 'NWDegNodeDuration.png' + 'title': 'Net Degree vs. Number of Nodes on Simulation Runtime', + 'path': 'NWDegVsNodeOnRuntime.png' + } + + self.plotHeatMapData(conf) + + # x -> network degree, y -> % of malicious nodes, weights -> no of missing samples + def plotNWDegVsMalNodeOnMissingSamples(self): + x = [result.shape.netDegree for result in self.results] + y = [result.shape.maliciousNodes for result in self.results] + weights = [result.missingVector[-1] for result in self.results] + + if len(set(x)) * len(set(y)) < 2: return # Not enough unique params for heatmap + + conf = { + 'x': x, + 'y': y, + 'weights': weights, + 'xlabel': 'Net Degree', + 'ylabel': 'Malicious Nodes (%)', + 'title': 'Net Degree vs Malicious Nodes (%) on Missing Samples', + 'path': 'NWDegVsMalNodeOnMissingSamples.png' } self.plotHeatMapData(conf) + + def plotAllHeatMaps(self): + self.plotNWDegVsNodeOnRuntime() + self.plotNWDegVsMalNodeOnMissingSamples() \ No newline at end of file diff --git a/study.py b/study.py index 7656e33..2aa6dc8 100644 --- a/study.py +++ b/study.py @@ -93,7 +93,7 @@ def study(): visual = Visualizor(execID, config, results) visual.plotHeatmaps("nn", "fr") - visual.plotNWDegVsNodeOnRuntime() + visual.plotAllHeatMaps() if __name__ == "__main__": study()