Skip to main content
  1. Posts/

Integrate R and Python for forecasting

··221 words·2 mins·

🔗 Integrate forecasting models in Python within the Tidyverse ecosystem
#

💡 An elegant solution to combine the best of both worlds:

  • 🐍 Advanced Python models (like nnetsauce and cybooster)
  • 📊 Data manipulation and visualization in R with dplyr, ggplot2 and plotly

This approach allows you to use non‑standard prediction models in Python and then process, validate, and visualize everything in R without losing the coherence of the tidy workflow.

🧩 What makes this integration special?
#

  • 🔌 Use of reticulate to connect the two languages.
  • 🔄 Conversion of Python predictions → R tibbles.
  • 🎨 Custom visualization in ggplot2, avoiding modeltime limitations.
  • 📉 Manual adjustment of confidence intervals based on actual MAPE, improving interpretation.

🟦 Explanation in a nutshell
#

Imagine Python is a very powerful engine for predicting the future, while R is the best place to tidy data and make beautiful charts.
This method builds a “bridge” between the two:

Python makes the predictions → R organizes them → R plots them.

That way you can use complex models without giving up the convenience of the Tidyverse.

More information at the link 👇

More in the following external reference.
Also published on LinkedIn.
Juan Pedro Bretti Mandarano
Author
Juan Pedro Bretti Mandarano