Machine Learning as a Service (MLaaS) API for Solar Flare Prediction

This MLaaS API (application programming interface) is designed to help users perform solar flare prediction as described in Liu et al. The MLaaS API offers users four prediction methods. These four methods are: (i) ensemble (ENS), (ii) random forests (RF), (iii) multilayer perceptrons (MLP), and (iv) extreme learning machines (ELM). ENS works by taking the majority vote of the results obtained from RF, MLP and ELM. The four prediction models are pretrained using the data described in Liu et al. which can be found in this link. This RESTful interface supports flare prediction using the pretrained models provided by DeepSun or your own custom model that is trained and created with your data. The API supports POST request to predict solar flare occurrence and GET request to get a random data sample from our training dataset.

Specifications:

Base URL

https://nature.njit.edu/spacesoft/MLaaS/api

Primary category

Solar flares

API provider

DeepSun

Schemes

Authentication

No authentication is required.

Client

Any programming language that supports HTTP calls, such as Java, C++, Python, Node.js, JavaScript modules in React or other frameworks, etc. can be used to invoke the API.

Request Methods Definitions:

Pretrained Model use our pretrained model.
POST
/spacesoft/MLaaS/api/v1/predict Predict solar flare occurrence.
Parameters

Name* required Description
body* required

(body)

Solar flares test data that needs to be predicted.

Parameter content type


Responses Response content type

Code* required Description
200
Valid response.

Example value:
GET
/spacesoft/MLaaS/api/v1/data Get a test data record sample.
Parameters

Name* required Description
query* required
string

(query)

Queries the database for a single test data record.
Available values : getsampledata

Request example:
/spacesoft/MLaaS/api/v1/data?query=getsampledata
Responses Response content type

Code* required Description
200
Success operation.

Example value:
This is an open access system. Authentication is not required.

Custom Model create your own model.
POST
/spacesoft/MLaaS/api/v1/train Train your data and create your own model.
Parameters

Name* required Description
body* required

(body)

Solar flare training data to train and create your own model.

Parameter content type


Responses Response content type

Code* required Description
200
Valid response.

Example value:

Client Examples:

In this section, we provide GET and POST client examples using Python, Java, and curl command.
Python client
This Python client example requires installing two moudles using the Python pip command. Execute the following two pip commands in your machine to install the modules.
  • pip install requests
  • pip install simplejson
Java client
This Java program includes both GET and POST examples. It retrieves the test record and uses it to predict the solar flare. It requires Java JDK in order to compile the program. You may download and install Java from Oracle web site in this link.
To compile and run the example, follow the instructions:
  • Install Java JDK from this link if you have not done already.
  • Copy, paste, and save the program code into a file named: SimpleHTTRequest.java
  • Compile the program file using Java compiler: javac -d . SimpleHTTRequest.java
    The compiler produces a binary file named: SimpleHTTRequest.class
  • Run the program using Java run time command: java -cp . SimpleHTTRequest
    Note: the binary program name without the extension .class and there a "." for the current director class path.
curl client
curl command is a tool to transfer data from or to a server using various protocols. It is a native Linux command but there exist packages for Windows too. Run the command in a machine command line terminal. This example is only for Linux.