def test_plotting(self): """ Testing the fit function and the image data when data are available """ plot = ScatterPlot(1) plot.set_data([0, 1], [0, 1]) img_data = plot.get_image_data() assert plot.get_fit_function() assert img_data
def plot(): """ This page displays a scatter plot of all gathered tweets The x-axis is the sentiment value. The y-axis is the weather value. The closer points are to the 'identity' line, the closer they fit our hypothesis """ scatter_plot = ScatterPlot(1) scatter_plot.load_data() img_data = scatter_plot.get_image_data() refresh = request.args.get('refresh', 0, type=int) if refresh: return img_data return render_template('plot.html', data=img_data)
def test_plotting_empty(self): """ Testing the fit function and the image data when no data is available or when weather data are random and thus not among the allowed discrete values """ plot = ScatterPlot(1) img_data = plot.get_image_data() assert not (plot.get_fit_function()) plot.set_data([random.random(), random.random()], [random.random(), random.random()]) assert not (plot.get_fit_function()) assert img_data
def test_plotting_empty(self): """ Testing the fit function and the image data when no data is available or when weather data are random and thus not among the allowed discrete values """ plot = ScatterPlot(1) img_data = plot.get_image_data() assert not(plot.get_fit_function()) plot.set_data([random.random(), random.random()], [random.random(), random.random()]) assert not(plot.get_fit_function()) assert img_data
def plotNetworkPerformance(bestPopulation, topology, fileName, networkSize): if(topology == Topology.Random): # Connectivity on x-axis and error on y-axis xAxis = [] yAxis = [] for item in bestPopulation: connectivity = item[0][0,0] error = item[1] xAxis.append(connectivity) yAxis.append(error) xAxis = np.array(xAxis) yAxis = np.array(yAxis) seriesName = "Network Size "+str(networkSize) # Plot the results scatter = plot.ScatterPlot(fileName, "Random Graph Connectivity Optimization using GA", "Connectivity vs Performance", "Connectivity", "MSE") scatter.setSeries(seriesName, xAxis, yAxis) scatter.createOutput()
averageDiameterList = np.array(averageDiameterList).reshape( len(averageDiameterList), 1)[:, 0] averageClusteringCoefficientList = np.array( averageClusteringCoefficientList).reshape( len(averageClusteringCoefficientList), 1)[:, 0] # # Plot 1 - Network parameters vs error # fileName = "/Attachment_Vs_Error.html" # scatter = plot.ScatterPlot(folderName+fileName, "Scale Free Networks Optimization using GA", "Attachment vs Performance", "Attachment", "Mean Square Error") # scatter.setSeries("Network Performance", attachmentList, errorList) # scatter.createOutput() # Plot 2 - Average degree vs error fileName = "/AverageDegree_Vs_Error.html" scatter = plot.ScatterPlot(folderName + fileName, "Small World Graphs Optimization using GA", "Average Degree vs Performance", "Average Degree", "Mean Square Error") scatter.setSeries("Network Performance", averageDegreeList, errorList) scatter.createOutput() # Plot 3 - Average path length vs error fileName = "/AveragePathLength_Vs_Error.html" scatter = plot.ScatterPlot(folderName + fileName, "Small World Graphs Optimization using GA", "Average Path Length vs Performance", "Average Path Length", "Mean Square Error") scatter.setSeries("Network Performance", averagePathLengthList, errorList) scatter.createOutput() # Plot 4 - Diameter vs error fileName = "/Diameter_Vs_Error.html"
averagePathLengthList.append(averagePathLength) averageDiameterList.append(averageDiameter) averageClusteringCoefficientList.append(averageClusteringCoefficient) attachmentList = np.array(attachmentList).reshape(len(attachmentList),1)[:,0] errorList = np.array(errorList).reshape(len(errorList),1)[:,0] averageDegreeList = np.array(averageDegreeList).reshape(len(averageDegreeList),1)[:,0] averagePathLengthList = np.array(averagePathLengthList).reshape(len(averagePathLengthList),1)[:,0] averageDiameterList = np.array(averageDiameterList).reshape(len(averageDiameterList),1)[:,0] averageClusteringCoefficientList = np.array(averageClusteringCoefficientList).reshape(len(averageClusteringCoefficientList),1)[:,0] # Plot 1 - Network parameters vs error fileName = "/Attachment_Vs_Error.html" scatter = plot.ScatterPlot(folderName+fileName, "Scale Free Networks Optimization using GA", "Attachment vs Performance", "Attachment", "Mean Square Error") scatter.setSeries("Network Performance", attachmentList, errorList) scatter.createOutput() # Plot 2 - Average degree vs error fileName = "/AverageDegree_Vs_Error.html" scatter = plot.ScatterPlot(folderName+fileName, "Scale Free Networks Optimization using GA", "Average Degree vs Performance", "Average Degree", "Mean Square Error") scatter.setSeries("Network Performance", averageDegreeList, errorList) scatter.createOutput() # Plot 3 - Average path length vs error fileName = "/AveragePathLength_Vs_Error.html" scatter = plot.ScatterPlot(folderName+fileName, "Scale Free Networks Optimization using GA", "Average Path Length vs Performance", "Average Path Length", "Mean Square Error") scatter.setSeries("Network Performance", averagePathLengthList, errorList)
0] errorList = np.array(errorList).reshape(len(errorList), 1)[:, 0] averageDegreeList = np.array(averageDegreeList).reshape( len(averageDegreeList), 1)[:, 0] averagePathLengthList = np.array(averagePathLengthList).reshape( len(averagePathLengthList), 1)[:, 0] averageDiameterList = np.array(averageDiameterList).reshape( len(averageDiameterList), 1)[:, 0] averageClusteringCoefficientList = np.array( averageClusteringCoefficientList).reshape( len(averageClusteringCoefficientList), 1)[:, 0] # Plot 1 - Network parameters vs error fileName = "/Probability_Vs_Error.html" scatter = plot.ScatterPlot(folderName + fileName, "Erdos Renyi Networks Optimization using GA", "Probability vs Performance", "Probability", "Mean Square Error") scatter.setSeries("Network Performance", attachmentList, errorList) scatter.createOutput() # Plot 2 - Average degree vs error fileName = "/AverageDegree_Vs_Error.html" scatter = plot.ScatterPlot(folderName + fileName, "Erdos Renyi Networks Optimization using GA", "Average Degree vs Performance", "Average Degree", "Mean Square Error") scatter.setSeries("Network Performance", averageDegreeList, errorList) scatter.createOutput() # Plot 3 - Average path length vs error fileName = "/AveragePathLength_Vs_Error.html"