Using the API

When AI model learning is completed, the API is automatically created. Automatically generated APIs can be used to link and distribute services with artificial intelligence models without any hassle.

View API

1. Click Training in the top navigation bar.

2. Click the Training Project with the model to see the API in the project list.

3. In the Model list at the bottom of the project, click the Details of the AI model that you want to check for the API.

4. Click the API in the tabs on the left-hand side of the center of the screen.

5. The API is available in a total of 4 languages.(JavaScript / Python / wget /Java)

Predicting with API

The code below is an example and may differ from the actual code.

Single Prediction

  1. Copy and paste the API in the appropriate language, and enter the input value for each parameter. Based on the code example below, parameter1~ means column name and test.csv means the data name used when training.

  2. After entering the input value in n for each parameter (column), you can check the result value.

import requests
import json

url = "http://0.0.0.0:xxxxx/predict/xxxxxx/"

payload = {"modelid":111111,"apptoken":"xxxxxx",
           "parameter": {"parameter1_test.csv":n,
                         "parameter2_test.csv":n,
                         "parameter3_test.csv":n,
                         "parameter4_test.csv":n,
                         "parameter5_test.csv":n,
                         "parameter6_test.csv":n,
                         "parameter7_test.csv":n}}
headers = {
             'content-type': "application/json",
             'cache-control': "no-cache",
           }

response = requests.request("POST", url, data=json.dumps(payload), headers=headers)

print(response.text)

Collective Prediction

  1. Save a number of rows with values for each column (parameter) as CSV file. (In this example, corresponding to test.csv)

  2. Enter row[0], row[1]... where you enter the addition of the sample variable and the input for each parameter, as shown in the code example below.

  3. Run the code and check the result value.

import requests
import json

url = "http://0.0.0.0:xxxxx/predict/xxxxxx/"

# sample = 샘플데이터
sample = pd.read_csv('test.csv', index_col=0)

for _, row in sample.iterrows():
    payload = {"modelid":111111,"apptoken":"xxxxxx",
               "parameter": {"parameter1_test.csv":row[0],
                             "parameter2_test.csv":row[1],
                             "parameter3_test.csv":row[2],
                             "parameter4_test.csv":row[3],
                             "parameter5_test.csv":row[4],
                             "parameter6_test.csv":row[5],
                             "parameter7_test.csv":row[6]}}
headers = {
             'content-type': "application/json",
             'cache-control': "no-cache",
           }

response = requests.request("POST", url, data=json.dumps(payload), headers=headers)

print(response.text)

Do you have any other questions? [email protected]

Last updated