This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import chart_studio.plotly as py | |
import plotly.graph_objs as go | |
from plotly.offline import init_notebook_mode, iplot | |
init_notebook_mode(connected=True) | |
import plotly | |
def predreport(y_pred, Y_Test): | |
diff = y_pred.flatten() - Y_Test.flatten() | |
perc = (abs(diff)/y_pred.flatten())*100 | |
priority = [] | |
for i in perc: | |
if i > 0.4: | |
priority.append(3) | |
elif i> 0.1: | |
priority.append(2) | |
else: | |
priority.append(1) | |
print("Error Importance 1 reported in ", priority.count(1), | |
"cases\n") | |
print("Error Importance 2 reported in", priority.count(2), | |
"cases\n") | |
print("Error Importance 3 reported in ", priority.count(3), | |
"cases\n") | |
colors = ['rgb(102, 153, 255)','rgb(0, 255, 0)', | |
'rgb(255, 153, 51)', 'rgb(255, 51, 0)'] | |
fig = go.Figure(data=[go.Table(header= | |
dict( | |
values=['Actual Values', 'Predictions', | |
'% Difference', "Error Importance"], | |
line_color=[np.array(colors)[0]], | |
fill_color=[np.array(colors)[0]], | |
align='left'), | |
cells=dict( | |
values=[y_pred.flatten(),Y_Test.flatten(), | |
perc, priority], | |
line_color=[np.array(colors)[priority]], | |
fill_color=[np.array(colors)[priority]], | |
align='left'))]) | |
init_notebook_mode(connected=False) | |
py.plot(fig, filename = 'Predictions_Table', auto_open=True) | |
fig.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment