Skip to content

Instantly share code, notes, and snippets.

@brockmanmatt
Created October 10, 2019 03:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brockmanmatt/f772a43f249222dffb2a443f37492143 to your computer and use it in GitHub Desktop.
Save brockmanmatt/f772a43f249222dffb2a443f37492143 to your computer and use it in GitHub Desktop.
h_predictions, *_ = learn.get_preds(DatasetType.Test)
#h_predictions = h_predictions.numpy()
v_predictions, *_ = learn.get_preds(DatasetType.Valid)
#h_predictions = h_predictions.numpy()
predictions, *_ = learn.get_preds(DatasetType.Train)
#predictions = predictions.numpy()
issue = "foxnews.com_russia"
results = time_series[[issue]][-52:]
results.columns = ["actual"]
results["predicted"] = (np.concatenate((predictions, v_predictions, h_predictions), axis=None))
results["m"] = results.actual[:len(predictions)].mean()
ax = results[["actual", "m"]].rename(columns={"m":"mean"}).plot(figsize=(12,8))
results["predicted"][:len(predictions)].plot(ax=ax, color="orangered", label="Train", title=issue)
results["predicted"][len(predictions)-1:-len(h_predictions)].plot(ax=ax, color="red", label="Validation")
results["predicted"][-len(h_predictions)-1:].plot(ax=ax, color="darkred", label="Test")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment