A web application for forecasting in Python, R, Ruby, C#, JavaScript, PHP, Go, Rust, Java, MATLAB, etc. | R-bloggers

A web application for forecasting in Python, R, Ruby, C#, JavaScript, PHP, Go, Rust, Java, MATLAB, etc. | R-bloggers

A web application for forecasting in Python, R, Ruby, C#, JavaScript, PHP, Go, Rust, Java, MATLAB, etc.
Posted on November 1, 2022 by T. Moudiki in R bloggers | 0 Comments
[This article was first published on T. Moudiki's Webpage - R , and kindly contributed to R-bloggers ]. (You can report issue about the content on this page here )
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
2 – Get a token for authentication
3 – Requests for forecasts
4 – On model calibration and cross-validation
0 – Intro
In this post, I’ll describe an (work-in-progress) Application Programming Interface (API) for time series forecasting. An API is a system that can receive requests from your computer, to carry out given tasks on given resources, and return a response. This type of system is programming-language-agnostic. That means: it can be used with Python, JavaScript, PHP, R, Go, C#, Ruby, Rust, Java, MATLAB, Julia, and any other programming language speaking http. And therefore, it could be relatively easily integrated into existing workflows for uncertainty forecasting. I’ve used the following tools for building it:
Python’s Flask for backend development
Bootswatch for the HTML/CSS theme
Plotly for interactive graphs
SQLAlchemy | PostgreSQL for database management
Swagger for API documentation
Salesforce’s Heroku (Cloud Application Platform) for deploying the application
The application is here:
https://techtonique2.herokuapp.com/
In the homepage (“/”), you can plot a time series by uploading a csv file, and pushing the button “Plot!”. Some examples of input files are stored on GitHub, at https://github.com/Techtonique/datasets/tree/main/time_series/univariate . Hover your cursor over the graph to see the options available, like downloading as png, zooming in and out, etc. Let’s describe the API now.
1 – Create an account:
In order to sign up, you can use your username or an email address. A valid email address is preferable, because usernames duplicates aren’t authorized in the database. You don’t want to spend your precious time trying to figure out which username hasn’t been registered yet! In addition, without a valid email address, you won’t be notified for changes and improvements in the API (e.g new forecasting models added, bugs fixes…).
Using curl
curl -X POST -H "Content-Type: application/json" -d '{"username":" [email protected] ","password":"pwd"}' https://techtonique2.herokuapp.com/api/users
If you want to translate these commands from curl to your favorite programming language (Python, JavaScript, PHP, R, Go, C#, Ruby, Rust, Elixir, Java, MATLAB, Dart, CFML, Ansible URI, Strest), you can simply use the following website: https://curlconverter.com/ . Of course, it’s important to choose a better password !
Using Python
In the near future, there will be a user-friendly Python package encapsulating these steps.
import requests headers = { # Already added when you pass json= # 'Content-Type': 'application/json', } json_data = { 'username': ' [email protected] ', 'password': 'pwd', } response = requests.post('https://techtonique2.herokuapp.com/api/users', headers=headers, json=json_data)
Using R
In the near future, there will be a user-friendly R package encapsulating these steps.
require(httr) headers = c( `Content-Type` = 'application/json' ) data = '{"username":" [email protected] ","password":"pwd"}' res

Images Powered by Shutterstock