-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathGraphs.py
44 lines (30 loc) · 1.26 KB
/
Graphs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Importing matplotlib for Visualizations
from matplotlib import pyplot
import matplotlib.animation as animation
import matplotlib.pyplot as plt
import pylab
# Importing operator to call operator.subtract
import operator
def plot_error(actualScores, predictedScores, graphName):
# Create a figure window
fig = plt.figure()
# Assert that length of predicted and actual scores must be equal
assert(len(predictedScores) == len(actualScores))
# Set x-axis values to the Answer IDs
x_axis_values = range(1, (len(predictedScores)+1) )
# Calculate errors in predictions:
predictionErrors = list(map(operator.sub, predictedScores, actualScores))
#plt.scatter(x_axis_values, actualScores, color='red', linestyle = "None", label = 'Actual Scores', s = 0.3)
#plt.scatter(x_axis_values, predictedScores, color='green', linestyle = "None", label = 'Predicted Scores', s = 0.3)
# Plot errors:
plt.errorbar(x_axis_values, predictedScores, yerr=predictionErrors, linestyle="None", color='red')
# Location of the Legend
pylab.legend(loc='upper left')
# Graph title
fig.suptitle(graphName)
# X-axis Label
plt.xlabel("Answer Number")
# Y-axis Label
plt.ylabel("Scores")
# Display the graph
plt.show()