Skip to content

Instantly share code, notes, and snippets.

@bkaankuguoglu
Last active May 15, 2021 14:16
Show Gist options
  • Save bkaankuguoglu/cc54617282acc33cc06cfbd388951587 to your computer and use it in GitHub Desktop.
Save bkaankuguoglu/cc54617282acc33cc06cfbd388951587 to your computer and use it in GitHub Desktop.
import plotly.offline as pyo
def plot_predictions(df_result, df_baseline):
data = []
value = go.Scatter(
x=df_result.index,
y=df_result.value,
mode="lines",
name="values",
marker=dict(),
text=df_result.index,
line=dict(color="rgba(0,0,0, 0.3)"),
)
data.append(value)
baseline = go.Scatter(
x=df_baseline.index,
y=df_baseline.prediction,
mode="lines",
line={"dash": "dot"},
name='linear regression',
marker=dict(),
text=df_baseline.index,
opacity=0.8,
)
data.append(baseline)
prediction = go.Scatter(
x=df_result.index,
y=df_result.prediction,
mode="lines",
line={"dash": "dot"},
name='predictions',
marker=dict(),
text=df_result.index,
opacity=0.8,
)
data.append(prediction)
layout = dict(
title="Predictions vs Actual Values for the dataset",
xaxis=dict(title="Time", ticklen=5, zeroline=False),
yaxis=dict(title="Value", ticklen=5, zeroline=False),
)
fig = dict(data=data, layout=layout)
iplot(fig)
# Set notebook mode to work in offline
pyo.init_notebook_mode()
plot_predictions(df_result, df_baseline)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment