Quick Start

Last updated: April 8th, 2019

Getting Started

Alpes API offers Classification Algorithm as a service and you are just one step away from using alpes NN to solve your Machine learning problems in your product.

This API has 4 simple steps Train, Test, Predict, Download and additionally you can also do Incremental Train whenever new data is arrived to train the model

API can be accessed via http://api.alpes.ai/ its is built using REST and JSON is returned by all API responses

Get an Invite

To get access to API send an email to hello@alpes.ai

Authentication

Authenticate your account by including your secret key in API requests. Api invite email contains your authentication token details. Pass the token in the http header in each request as below

-H 'authorization: Token 401f7ac837dafgfgfgg613d789819ff93537bee6a' \

API calls

Upload

upload api calls allows you to upload your train/test data to server which can be fed to train and test methods. currently we accept CSV and ZIP files only with class-label as the first column. Zip file should contain only the zip of one file not a folder or multiple files.

Python code example:

import requests
import json
url = 'http://api.alpes.ai/snn/dataupload'
files = {'file': (open('../data/train.zip', 'rb').read())}
params = {'file_type': 'zip'}
headers = {'authorization': "Token 512f7ac837da42b97f613d789819ff93537bee6a"}
r = requests.post(url,files=files,headers=headers,params=params)
print (json.loads(r.text))

the api call returns uploded filename as the response which will be used in the later api calls

{u'filename': u'file9626271.csv'}

Train

Train API call performs train with Alpes NN upload api calls allows you to upload your train/test data to server which can be fed to train and test methods. currently we accept CSV files only with Class-label as the first coloum.

Parameters for Training API call.
# Param name Required Value Comments
1 uplodedfileid yes 'file9626271.csv' pass the file id which is in the response of the upload api call.
2 no_of_initial_planes yes 3 keep this value around 3 to 10 based on the number of train points. if you train points are in the range of 50K to 100K then 3-5 initial planes should be good enough increase this value if the train data is large.
3 min_trainpoints_to_be_covered yes 0.99 The value for this param should be in the range of 1 to 0.65, if the data is very vary sparse some times training takes lot of time. for better convergence you can reduce the min trainpoints to be converted to some value like 0.7 or 0.8 so that it converges faster by ignoring some of the train data
4 epoch yes 1 this value is same as epoch in the neural network sense. ideally this should be less than 6 in most cases 1-3 should give good results.
Python code example:

import requests
import json
url = 'http://api.alpes.ai/snn/train'
headers = {'authorization': "Token 512f7ac837da42b97f613d789819ff93537bee6a"}
params = {
            'uplodedfileid': 'file9626271.csv',
            'no_of_initial_planes':3,
            'min_trainpoints_to_be_covered':0.98,
            'epoch':1
        }
r = requests.post(url,params=params,headers=headers)
print (json.loads(r.text))

Traing is performed as a background task, the api response will have the job id of the task. you can use the job_id to fetch the results of the training or to find the status of the task.

{u'job_id': u'da399c36-3779-491f-b6b4-5bbe84bf8a91'}

Get Status

This API call gives the status of the Train and Test API calls. sample code is shared below

Python code example:

import requests
import json

url = 'http://api.alpes.ai/snn/job_status/'
#format of the url should be api url + {job_id}

url = url + 'da399c36-3779-491f-b6b4-5bbe84bf8a91'
job_info = requests.get(url)
print (json.loads(job_info.text))

the api call returns status (Success/Failed/pending etc) and the result of the train call with details such as train time and the model name

{u'status': u'SUCCESS', u'result': u"{'traintime': '[Thu, 18 Oct 2018 06:41:55 IST] Elapsed Time: 00:00:0.545007', 'model': u'model_2382879'}"}

Test

With Test api call you can perform a quick test on your models to get the accuracy score

Parameters for Test API call.
# Param name Required Value Comments
1 uplodedfileid yes 'file9626271.csv' pass the file id which is in the response of the upload api call.
2 model yes model_3552151 model name will be present in the results of the train api call. pass on the same model name here to perform the test on the model
3 kvalue yes 3 This K value is something similar to K value in the KNN ideally pass some odd number < 15 like 3, 5 etc
4 nbest yes 0.1 depending on the size of your data this value should be with in the range of 0.001 to 0.3. normally 0.1 should be good value of most data set's with 50K samples
Python code example:

import requests
import json
url = 'http://api.alpes.ai/snn/test'
headers = {'authorization': "Token 512f7ac837da42b97f613d789819ff93537bee6a"}
params = {'uplodedfileid': u'liver.csv','model':'model_3552151','kvalue': 3,'nbest': 0.1}
r = requests.post(url,params=params,headers=headers)
print (json.loads(r.text))

Test is performed as a background task, the api response will have the job id of the task. you can use the job_id to fetch the results of the training or to find the status of the task.

{u'job_id': u'a02f1dfc-2a99-4bb8-a668-5a7f8b370538'}

using this job_id call get Status API to get the Test Results. sample results are below

{u'status': u'SUCCESS', u'result': u"{'accuracy_score': 93.36384439359267}"}

Predict

Predict API call performs predictiction using Alpes NN

Parameters for Predict API call.
# Param name Required Value Comments
1 test_features yes '0.8,0.2,0.6,112,24,33,16,7.6,4.1,3.5,1.2' pass the feature vector for your test data as a string
2 model yes model_3552151 model name will be present in the results of the train api call. pass on the same model name here to perform the prediction on the model
3 kvalue yes 3 This K value is something similar to K value in the KNN ideally pass some odd number < 15 like 3, 5 etc
4 nbest yes 0.1 depending on the size of your data this value should be with in the range of 0.001 to 0.3. normally 0.1 should be good value of most data set's with 50K samples
Python code example:

import requests
import json
url = 'http://api.alpes.ai/snn/predict'
headers = {'authorization': "Token 512f7ac837da42b97f613d789819ff93537bee6a"}
params = {'model':'model_3552151','kvalue': 3,'nbest': 0.1}
data = {'test_features':'0.8,0.2,0.6,112,24,33,16,7.6,4.1,3.5,1.2'}
r = requests.post(url,params=params,json=data,headers=headers)
print (json.loads(r.text))

Predict response gives the class label for the test data.

{u'predected_label': 1}

Predict Closest

Predict Closest API call performs predictiction of set of nearest train data points for a given test data using Alpes NN

Parameters for Predict Closest API call.
# Param name Required Value Comments
1 test_features yes '0.8,0.2,0.6,112,24,33,16,7.6,4.1,3.5,1.2' pass the feature vector for your test data as a string
2 model yes model_3552151 model name will be present in the results of the train api call. pass on the same model name here to perform the prediction on the model
3 kvalue yes 3 This K value is something similar to K value in the KNN ideally pass some odd number < 15 like 3, 5 etc
4 nbest yes 0.1 depending on the size of your data this value should be with in the range of 0.001 to 0.3. normally 0.1 should be good value of most data set's with 50K samples
Python code example:

import requests
import json
url = 'http://api.alpes.ai/snn/predictclosest'
headers = {'authorization': "Token 512f7ac837da42b97f613d789819ff93537bee6a"}
params = {'model':'model_3552151','kvalue': 3,'nbest': 0.1}
data = {'test_features':'0.8,0.2,0.6,112,24,33,16,7.6,4.1,3.5,1.2'}
r = requests.post(url,params=params,json=data,headers=headers)
print (json.loads(r.text))

Predict Closest response gives the set of nearest train data points for the test data

Incremental Train

With Incremental train api call you can perform a incremental training on your base models without doing full re-training with the complete data.

Parameters for Incremental Train API call.
# Param name Required Value Comments
1 uplodedfileid yes 'file9626271.csv' pass the file id which is in the response of the upload api call.
2 model yes model_3552151 model name will be present in the results of the train api call. pass on the same model name here to perform the test on the model
3 min_trainpoints_to_be_covered yes 0.99 The value for this param should be in the range of 1 to 0.65, if the data is very vary sparse some times training takes lot of time. for better convergence you can reduce the min trainpoints to be converted to some value like 0.7 or 0.8 so that it converges faster by ignoring some of the train data
Python code example:

import requests
import json
url = 'http://api.alpes.ai/snn/inctrain'
headers = {'authorization': "Token 512f7ac837da42b97f613d789819ff93537bee6a"}
params = {'uplodedfileid': u'liver.csv','model': 'model_3552151','min_trainpoints_to_be_covered':0.9}
r = requests.post(url,params=params,headers=headers)
print (json.loads(r.text))

Incremental Training is performed as a background task, the api response will have the job id of the task. you can use the Get Status api call with job_id to fetch the results of the incremental training.

{u'job_id': u'a02f1dfc-2a99-4bb8-a668-5a7f8b370538'}

using this job_id call Get Status API to get the results of incremental training. sample results are below

{u'status': u'SUCCESS', u'result': u"{'traintime': '[Mon, 22 Oct 2018 12:37:02 IST] Elapsed Time: 00:00:1.023233', 'model': u'model_3552151'}"}

API walkthrough

This notebook will give you simple walkthrough of the Train test and predict API flow Sample API Notebook