Python Guide
This is our Python Guide for ML development. See Tables. Below
Table 1. vai_toolkit.client()
| Method | Description |
|---|---|
| client.create_organization() | This method is used to create organization for user. |
| client.update_name() | This method is used to update user's first name and last name. |
| client.update_password() | This method is used to update user password. |
Table 2. vai_toolkit.pipeline()
| Method | Description |
|---|---|
| pipeline.create() | This method is used to create pipeline of provided user. |
| pipeline.create_alert() | This method is used to create alert for given pipeline of user. |
| pipeline.create_table() | This method is used to create table for given pipeline of user. |
| pipeline.delete_pipeline() | This method is used to delete pipeline when there is no dataset in pipeline. |
| pipeline.delete_table() | This method is used to delete table for given pipeline of user. |
| pipeline.get_table() | This method is used to get tables of given pipeline of user. |
| pipeline.list_alerts() | This method is used to get the list of alerts for given pipeline of user. |
| pipeline.set_default_table() | This method is used to set default table for given pipeline of user. |
| pipeline.update_table() | This method is used to update table name for given pipeline of user. |
Table 3. vai_toolkit.data()
| Method | Description |
|---|---|
| data.delete_data() | This method is used to delete dataset data for given range in pipeline of user. |
| data.download_csvs() | This method is used to download dataset for given pipeline of user. |
| data.list_labels() | This method is used to get labels for given pipeline of user. |
| data.set_labels() | This method is used to set labels for given pipeline of user. |
| data.set_relations() | This method is used to set relations between tables of given pipeline of user. |
| data.upload_csv() | This method is used to upload csv for given pipeline of user |
| data.upload_data() | This method is used to upload data for given pipeline of user. |
Table 4. vai_toolkit.model()
| Method | Description |
|---|---|
| model.explain() | This method is used to get explanability values of specific record for given pipeline of user with options "NEXT_SERIES" or "MIXED" or "NEXT_LINK", if "NEXT_SERIES" then get explanability values of specific record with timeseries on for given pipeline of user and if "MIXED" then get explanability values of specific record with timeseries off for given pipeline of user. |
| model.history() | This method is used to get history of given model. |
| model.predict() | This method is used to get prediction of table count with different model two options available "NEXT_SERIES" and "NEXT_LINK". |
| model.train() | This method is used to train model with options "NEXT_SERIES", "MIXED" and "NEXT_LINK", if "NEXT_SERIES" then model will be trained with timeseries on for given pipeline of user and if "MIXED" then model will be trained with timeseries off for given pipeline of user. |
| model.delete() | This method is used to delete given model. |
| model.retrain() | This method is used to retrain given model. |
vai_toolkit.client
create_organization(user_secret, name, users)
This method is used to create organization for user.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Example
from vai_toolkit import client
org_name = "ORGANIZATION_NAME"
users = { 'john.deo@gmail.com' : 'ADMIN' }
user_secret = 'USER_SECRET_KEY'
res = client.create_organization(user_secret, org_name, users)
print(res)
Output
{
"user": "61efccd707170700131a87v2",
"name": "ORGANIZATION_NAME",
"datasetS3TotalSize": 0,
"isDeleted": false,
"createdAt": "2023-07-19T05:34:13.391Z",
"updatedAt": "2023-07-19T05:34:13.391Z",
"_id": "64b775d5f0a90246a2a2c31cd"
}
update_name(user_secret, first_name, last_name)
This method is used to update user's first name and last name.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Example
from vai_toolkit import client
user_secret = 'USER_SECRET_KEY'
first_name = 'John'
last_name = 'Deo'
updated_pass = client.update_name(user_secret ,first_name ,last_name )
print(updated_pass)
Output
{
"email": "john.deo@gmail.com",
"_id": "61efccd707170700131a87c2",
"firstName": "John",
"lastName": "Deo",
}
update_password(user_secret, new_password)
This method is used to update user password.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Example
from vai_toolkit import client
user_secret = 'USER_SECRET_KEY'
new_password = 'NEW_SECURE_PASSWORD'
res = client.update_password(user_secret, password)
print(res)
Output
{
"message": "Password changed successfully!.."
}
vai_toolkit.pipeline
create(user_secret, title, type)
This method is used to create pipeline of provided user.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Example
from vai_toolkit import pipeline
title = "Tabular data"
type = "TABULAR"
user_secret = 'USER_SECRET_KEY'
res = pipeline.create(user_secret, title, type)
print(res)
Output
{
'_id': '65017bdc104c04cd9663ba05',
'title': 'Tabular data',
'apiKey': 'd2159682-aecc-49cf-ba7d-a8bfcc828d5e-1694596060912'
}
create_alert(user_secret, pipeline_key, settings)
This method is used to create alert for given pipeline of user.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Example
from vai_toolkit import pipeline
user_secret = 'USER_SECRET_KEY'
pipeline_key = 'PIPELINE_KEY'
data ={
"name":"test",
"type":"DATASET",
"from": "1/1/2023",
"to": "12/31/2023",
"columnFields": ["race", "hours-per-week", "age"],
"week": 2,
"thresholdLimit": 49
}
res = pipeline.create_alert(user_secret, pipeline_key ,data)
print(res)
Output
{
'name': 'test',
'type': 'DATASET',
'pipelineId': '65017bdc104c04cd9663ba05',
'modelId': None,
'creator': '62c56baeb4fbc200139daed0',
'from': '1/1/2023',
'to': '12/31/2023',
'columnFields': ['race', 'hours-per-week', 'age'],
'week': 2,
'thresholdLimit': 49,
'timeWindow': {
'window': None,
'startTime': None,
'endTime': None,
'column': None,
'dates': [],
'times': [],
'isHoliday': None,
'holidays': [],
'step': None
},
'createdAt': '2023-09-13T09:13:10.080Z',
'updatedAt': '2023-09-13T09:13:10.080Z',
'_id': '65017d26104c04cd9663c23e'}
create_table(user_secret, pipeline_key, name)
This method is used to create table for given pipeline of user.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Example
from vai_toolkit import pipeline
user_secret = 'USER_SECRET_KEY'
pipeline_key = 'PIPELINE_KEY'
name = 'TABLE NAME'
res = pipeline.create_table(user_secret, pipeline_key ,data)
print(res)
Output
{
'success': True,
'table': {'name': 'Table Name','pipeline': 'Pipeline id', '_id': 'Table Id'}
}
delete_pipeline(user_secret, pipeline_key)
This method is used to delete pipeline when there is no dataset in pipeline
| Parameters: |
|
|---|
| Returns: |
|
|---|
Example
from vai_toolkit import pipeline
user_secret = 'USER_SECRET_KEY'
pipeline_key = 'PIPELINE_KEY'
res = pipeline.delete_pipeline(user_secret, pipeline_key )
print(res)
Output
{
message: "Pipeline deleted successfully!.."
}
delete_table(user_secret, pipeline_key, name)
This method is used to delete table for given pipeline of user.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Example
from vai_toolkit import pipeline
user_secret = 'USER_SECRET_KEY'
pipeline_key = 'PIPELINE_KEY'
name = 'TABLE NAME TO DELETE'
res = pipeline.delete_table(user_secret, pipeline_key ,name)
print(res)
Output
Table deleted successfully.
get_table(user_secret, pipeline_key)
This method is used to get tables of given pipeline of user.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Example
from vai_toolkit import pipeline
user_secret = 'USER_SECRET_KEY'
pipeline_key = 'PIPELINE_KEY'
res = pipeline.get_table(user_secret, pipeline_key )
print(res)
Output
[
{
name : 'TABLE NAME',
_id : 'Table id',
pipeline : 'Pipeline id'
},
{
name : 'TABLE NAME 2',
_id : 'Table id',
pipeline : 'Pipeline id'
},
]
list_alerts(user_secret, pipeline_key)
This method is used to get the list of alerts for given pipeline of user.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Example
from vai_toolkit import pipeline
user_secret = 'USER_SECRET_KEY'
pipeline_key = 'PIPELINE_KEY'
res = pipeline.list_alerts(user_secret, pipeline_key)
print(res)
Output
[
{
'timeWindow': {
'window': None,
'startTime': None,
'endTime': None,
'column': None,
'dates': [],
'times': [],
'isHoliday': None,
'holidays': [],
'step': None
},
'_id': '65017d26104c04cd9663c23e',
'name': 'test',
'type': 'DATASET',
'pipelineId': '65017bdc104c04cd9663ba05',
'modelId': None,
'creator': '62c56baeb4fbc200139daed0',
'from': '1/1/2023',
'to': '12/31/2023',
'columnFields': ['race', 'hours-per-week', 'age'],
'week': 2,
'thresholdLimit': 49,
'createdAt': '2023-09-13T09:13:10.080Z',
'updatedAt': '2023-09-13T09:13:10.080Z'
}
]
set_default_table(user_secret, pipeline_key, name)
This method is used to set default table for given pipeline of user.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Example
from vai_toolkit import pipeline
user_secret = 'USER_SECRET_KEY'
pipeline_key = 'PIPELINE_KEY'
name = 'TABLE NAME TO SET DEFAULT'
res = pipeline.set_default_table(user_secret, pipeline_key ,name)
print(res)
Output
Default table successfully.
update_table(user_secret, pipeline_key, old_name, new_name)
This method is used to update table name for given pipeline of user.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Example
from vai_toolkit import pipeline
user_secret = 'USER_SECRET_KEY'
pipeline_key = 'PIPELINE_KEY'
old_name = 'TABLE NAME'
new_name = 'NEW TABLE NAME'
res = pipeline.update_table(user_secret, pipeline_key ,old_name, new_name)
print(res)
Output
Name updated successfully.
vai_toolkit.data
delete_data(user_secret, pipeline_key, from_date, to_date, table_name='')
This method is used to delete dataset data for given range in pipeline of user.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Example
from vai_toolkit import data
user_secret = 'USER_SECRET_KEY'
pipeline_key = 'PIPELINE_KEY'
from_date = "09/06/2023" # From Date
to_date = "09/06/2023" # From Date
table='Table 2'
res = data.delete_data(user_secret, pipeline_key, from_date, to_date, table )
print(res)
Output
{
"message": "Deleted successfully!.."
}
download_csvs(user_secret, pipeline_key, to_file, from_date='', to_date='', table_name='')
This method is used to download dataset for given pipeline and table of user.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Example
from vai_toolkit import data
user_secret = 'USER_SECRET_KEY'
pipeline_key = 'PIPELINE_KEY'
from_date = "09/01/2023" # From Date
to_date = "09/11/2023" # From Date
path = "./new2.zip" #Path
table='Table 2'
res = data.download_csvs(user_secret, pipeline_key, path, from_date=from_date, to_date=to_date,table_name=table)
print(res)
list_labels(user_secret, pipeline_key, table_name='')
This method is used to get labels for given pipeline and table of user.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Example
from vai_toolkit import data
user_secret = 'USER_SECRET_KEY'
pipeline_key = 'PIPELINE_KEY'
table_name = 'Table 2'
res = data.list_labels(user_secret, pipeline_key,table_name =table_name )
print(res)
Output
{
'success': True,
'details': {
'Table Name': 'Table 2',
'Column Names': ['id', 'Capital Gain'],
'Column Types': ['CATEGORY', 'CATEGORY'],
'Column Labels': [None, None]
}
}
set_labels(user_secret, pipeline_key, labels, d_types, table_name='')
This method is used to set labels for given pipeline and table of user.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Example
from vai_toolkit import data
user_secret = 'USER_SECRET_KEY'
pipeline_key = 'PIPELINE_KEY'
columnLabels = { "id" : 'Input' ,"Capital Gain" : 'Output' } # Column Labels
columnTypes ={ "id" : 'CATEGORY',"Capital Gain" : 'CATEGORY' } # Column Types
table_name = 'Table 2'
res = data.set_labels(user_secret, pipeline_key, columnLabels, columnTypes,table_name)
print(res)
Output
{
'tableName': 'dim_item',
'columnLabels': [None, 'Output', None, None, 'Input', None, None, None, None],
'columnNames': ['A1', 'DimItemkey', 'RestaurantCustomerName', 'PLU', 'ItemDescription', 'ItemSubcategory', 'ItemCategory', 'ItemReportingCategory', 'ItemFNBCategory'],
'columnTypes': ['CATEGORY', 'CATEGORY', 'CATEGORY', 'CATEGORY', 'STRING', 'CATEGORY', 'CATEGORY', 'CATEGORY', 'CATEGORY'],
'pipeline': 'pipeline id',
'_id': 'Table id'
}
set_relations(user_secret, pipeline_key, primary_keys_obj, to_table, relation_array)
This method is used to set relations between tables of given pipeline of user.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Example
from vai_toolkit import data
user_secret = 'USER_SECRET_KEY'
pipeline_key = 'PIPELINE_KEY'
primary_keys_obj = {
"dim_item": "PLU",
"check": "CheckKey",
"check_item": "CheckItemKey"
}
to_table = "check_item"
relation_array = [
{
"from": "dim_item",
"toColumn": "ItemNumber"
},
{
"from": "check",
"toColumn": "CheckKey"
}
]
res = data.set_relations(user_secret, pipeline_key, primary_keys_obj, to_table, relation_array)
print(res)
Output
{
"message": "Updated successfully."
}
upload_csv(user_secret, pipeline_key, path, table_name)
This method is used to upload csv for given pipeline and table of user.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Example
from vai_toolkit import data
user_secret = 'USER_SECRET_KEY'
pipeline_key = 'PIPELINE_KEY'
table_name = 'Table 1'
res = data.upload_csv(user_secret, pipeline_key, "./09-11-2023.csv", table_name)
print(res)
Output
Dataset uploaded succesfully.
upload_data(user_secret, pipeline_key, data, date, time, new_columns=False, duplicates=False, new_categories=False, table_name='')
This method is used to upload data for given pipeline and table of user.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Example
from vai_toolkit import data
user_secret = 'USER_SECRET_KEY'
pipeline_key = 'PIPELINE_KEY'
uploadData = { "id": [11111, 1], "Capital Gain": [10000, 15000] } # Columns data
dates = ["09-06-2023", "09-06-2023"] # Dates
times = ["11:08:50", "11:09:50" ] # Times
table_name = 'Table 2'
res = data.upload_data(user_secret, pipeline_key, uploadData, dates, times, new_columns = True, duplicates = True,new_categories = True ,table_name=table_name)
print(res)
Output
{
'success': True,
'data': '{
"dates":["09-06-2023"]
}',
'warning': 'We insert the duplicate data if we found.'}
vai_toolkit.model
delete(user_secret, pipeline_key, model_key)
This method is used to delete model of provided pipeline.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Example
from vai_toolkit import pipeline
user_secret = 'USER_SECRET_KEY'
pipeline_key = 'PIPELINE_KEY'
model_key = 'MODEL_KEY'
res = model.delete(user_secret, pipeline_key ,model_key)
print(res)
Output
Model deleted successfully.
explain(user_secret, pipeline_key, model_key, datasetData=None, dataset=None, from_date=None, to_date=None, config=None, option='')
This method is used to get explanability values of specific record for given pipeline of user with two options "NEXT_SERIES" or "MIXED", if "NEXT_SERIES" then get explanability values of specific record with timeseries on for given pipeline of user and if "MIXED" then get explanability values of specific record with timeseries off for given pipeline of user.
| Parameters: |
|
|---|
| Other parameters: |
|
|---|
| Returns: |
|
|---|
Example
from vai_toolkit import model
user_secret = 'USER_SECRET_KEY'
pipeline_key = 'PIPELINE_KEY'
model_key ='MODEL_KEY'
from_date = '03/01/2023'
to_date = '05/31/2023'
option='NEXT_SERIES'
res = model.explain(user_secret, pipeline_key, model_key ,from_date=from_date,to_date=to_date,option=option)
print(res)
from vai_toolkit import model
user_secret = 'USER_SECRET_KEY'
pipeline_key = 'PIPELINE_KEY'
model_key ='MODEL_KEY'
datasetData ={
"hours-per-week": 35,
"age" : 40,
"loan-approved":0,
"capital-gain": 0,
"capital-loss": 0,
"education": "HS-grad",
"education-num": 9,
"marital-status": "Never-married",
"native-country": "United-States",
"occupation": "Transport-moving",
"race": "Non-white",
"relationship": "Not-in-family",
"sex": "Male",
"workclass": "Private"
}
dataset ="08-31-2023"
res = model.explain(user_secret, pipeline_key,model_key, datasetData=datasetData,dataset=dataset, option="MIXED" )
print(res)
from vai_toolkit import model
user_secret = 'USER_SECRET_KEY'
pipeline_key = 'PIPELINE_KEY'
model_key ='MODEL_KEY'
config ={
"seedNodeNameCol" : 'ItemDescription',
"prediction" : 10,
"seedNodeNames" : ["1","2"],
"refNodeDict" : {
"GuestCount" :0,
"CheckOpen" : "2023-09-08T05:14:05.283Z",
}}
option ='NEXT_LINK'
res = model.explain(user_secret, pipeline_key, model_key, config=config, option=option)
print(res)
Output
{
"data": {
"errorMessage": "",
"traceback": "",
"data": {
"y": [
{
"date": "01-16-2022",
"counts": "[{"tableCount":22.3249225616,"time":11},{"tableCount":15.3308525085,"time":12},{"tableCount":6.0051803589,"time":13},{"tableCount":6.4271569252,"time":14},{"tableCount":3.3630287647,"time":15},{"tableCount":2.7648005486,"time":16},{"tableCount":5.4221305847,"time":17},{"tableCount":21.0307579041,"time":18},{"tableCount":17.9799308777,"time":19},{"tableCount":11.0987033844,"time":20},{"tableCount":7.7918105125,"time":21}]"
},
{
"date": "01-17-2022",
"counts": "[{"tableCount":4.3347301483,"time":11},{"tableCount":13.7139158249,"time":12},{"tableCount":22.5580196381,"time":13},{"tableCount":17.7829666138,"time":14},{"tableCount":10.4020938873,"time":15},{"tableCount":2.7406756878,"time":16},{"tableCount":4.4894299507,"time":17},{"tableCount":3.9393897057,"time":18},{"tableCount":2.5602560043,"time":19},{"tableCount":5.2975172997,"time":20},{"tableCount":24.4320220947,"time":21}]"
},
{
"date": "01-18-2022",
"counts": "[{"tableCount":25.5556297302,"time":11},{"tableCount":21.6066265106,"time":12},{"tableCount":16.9466266632,"time":13},{"tableCount":13.0571289062,"time":14},{"tableCount":22.881313324,"time":15},{"tableCount":34.0851211548,"time":16},{"tableCount":28.8900508881,"time":17},{"tableCount":23.1612758636,"time":18},{"tableCount":13.7236795425,"time":19},{"tableCount":12.1094703674,"time":20},{"tableCount":8.7841835022,"time":21}]"
},
{
"date": "01-19-2022",
"counts": "[{"tableCount":6.8754734993,"time":11},{"tableCount":9.8974742889,"time":12},{"tableCount":29.4479675293,"time":13},{"tableCount":33.2332077026,"time":14},{"tableCount":26.8839187622,"time":15},{"tableCount":22.5158405304,"time":16},{"tableCount":21.4588184357,"time":17},{"tableCount":31.3786964417,"time":18},{"tableCount":41.555103302,"time":19},{"tableCount":38.0847129822,"time":20},{"tableCount":33.7989006042,"time":21}]"
},
{
"date": "01-20-2022",
"counts": "[{"tableCount":21.2980632782,"time":11},{"tableCount":16.9026260376,"time":12},{"tableCount":9.3885774612,"time":13},{"tableCount":5.1352725029,"time":14},{"tableCount":8.3074045181,"time":15},{"tableCount":26.5341453552,"time":16},{"tableCount":32.1234817505,"time":17},{"tableCount":29.40417099,"time":18},{"tableCount":25.5267181396,"time":19},{"tableCount":18.9728393555,"time":20},{"tableCount":21.9795360565,"time":21}]"
},
{
"date": "01-21-2022",
"counts": "[{"tableCount":26.9185009003,"time":11},{"tableCount":23.7499847412,"time":12},{"tableCount":19.7978839874,"time":13},{"tableCount":10.8758878708,"time":14},{"tableCount":9.7679300308,"time":15},{"tableCount":4.2197132111,"time":16},{"tableCount":0.0849183798,"time":17},{"tableCount":2.3076190948,"time":18},{"tableCount":18.9048557281,"time":19},{"tableCount":22.7209529877,"time":20},{"tableCount":19.5034141541,"time":21}]"
},
{
"date": "01-22-2022",
"counts": "[{"tableCount":16.1986370087,"time":11},{"tableCount":9.5400733948,"time":12},{"tableCount":11.5875263214,"time":13},{"tableCount":16.3533973694,"time":14},{"tableCount":13.4710626602,"time":15},{"tableCount":9.5767259598,"time":16},{"tableCount":3.3179194927,"time":17},{"tableCount":6.832379818,"time":18},{"tableCount":5.7702031136,"time":19},{"tableCount":3.5545077324,"time":20},{"tableCount":4.9158325195,"time":21}]"
}
],
"x": "",
"note": "predicting without explanation"
}
}
}
{
"success": true,
"output": {
"loan-approved": {
"inputs": {
"age": [
0.056
],
"capital-loss": [
0
],
"education": [
-0.037
],
"education-num": [
-0.008
],
"hours-per-week": [
0.113
],
"native-country": [
-0.006
],
"occupation": [
-0.019
],
"relationship": [
0.05
],
"workclass": [
-0.011
]
},
"outputs": [
0.138
]
}
},
"payload": {
"model": "dev/models/5e99761f522f057aeb4ed3c4/64412fa37a5a840c036a3fce/64a526df900b514e57881ef5_0.1_100_1000_1_17",
"x": {
"age": {
"type": "NUMBER",
"values": [
48
]
},
"capital-loss": {
"type": "CATEGORY",
"values": [
0
]
},
"hours-per-week": {
"type": "NUMBER",
"values": [
60
]
},
"workclass": {
"type": "CATEGORY",
"values": [
"Self-emp-not-inc"
]
},
"education": {
"type": "CATEGORY",
"values": [
"HS-grad"
]
},
"education-num": {
"type": "CATEGORY",
"values": [
9
]
},
"occupation": {
"type": "CATEGORY",
"values": [
"Craft-repair"
]
},
"relationship": {
"type": "CATEGORY",
"values": [
"Husband"
]
},
"native-country": {
"type": "CATEGORY",
"values": [
"England"
]
}
},
"y": {
"loan-approved": {
"type": "CATEGORY"
}
},
"file_paths": [
"dev/dataset-files/5e99761f522f057aeb4ed3c4/64412fa37a5a840c036a3fce/64412fd67a5a840c036a40fd/04-14-2023.csv"
]
},
"response": {
"StatusCode": 200,
"ExecutedVersion": "$LATEST",
"Payload": "{"errorMessage": "", "traceback": "", "data": {"loan-approved": {"inputs": {"age": [0.056], "capital-loss": [0.0], "education": [-0.037], "education-num": [-0.008], "hours-per-week": [0.113], "native-country": [-0.006], "occupation": [-0.019], "relationship": [0.05], "workclass": [-0.011]}, "outputs": [0.138]}}}"
}
}
history(user_secret, pipeline_key, model_key, limit=5)
This method is used to get history of given model.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Example
from vai_toolkit import model
user_secret = 'USER_SECRET_KEY'
pipeline_key = 'PIPELINE_KEY'
model_key = 'MODEL_KEY'
limit = 5
res= model.history( user_secret, pipeline_key, model_key, limit)
print(res)
Output
[
{
"id": "65260a39bb6b899f4d789222",
"input": {
"fromDate": "12/21/2022",
"toDate": "12/31/2022"
},
"output": {
"data": {
"errorMessage": "",
"traceback": "",
"data": {
"y": [
{
"date": "01-01-2023",
"counts": "[{"tableCount":8.1729021072,"time":11},{"tableCount":9.2272834778,"time":12},{"tableCount":8.7410840988,"time":13},{"tableCount":7.2610864639,"time":14},{"tableCount":4.7990121841,"time":15},{"tableCount":4.9796061516,"time":16},{"tableCount":5.1875333786,"time":17},{"tableCount":6.0545682907,"time":18},{"tableCount":6.2240757942,"time":19},{"tableCount":6.6397485733,"time":20},{"tableCount":6.5043768883,"time":21}]"
},
{
"date": "01-02-2023",
"counts": "[{"tableCount":5.9584774971,"time":11},{"tableCount":4.71900177,"time":12},{"tableCount":5.23458004,"time":13},{"tableCount":5.9814653397,"time":14},{"tableCount":5.5183796883,"time":15},{"tableCount":6.3703117371,"time":16},{"tableCount":3.9970772266,"time":17},{"tableCount":1.6930608749,"time":18},{"tableCount":2.1605021954,"time":19},{"tableCount":2.2661693096,"time":20},{"tableCount":4.5692014694,"time":21}]"
},
{
"date": "01-03-2023",
"counts": "[{"tableCount":4.8561573029,"time":11},{"tableCount":5.6609015465,"time":12},{"tableCount":3.6423728466,"time":13},{"tableCount":4.340628624,"time":14},{"tableCount":7.3471589088,"time":15},{"tableCount":8.417137146,"time":16},{"tableCount":11.6935253143,"time":17},{"tableCount":13.3711690903,"time":18},{"tableCount":12.0397434235,"time":19},{"tableCount":9.6431388855,"time":20},{"tableCount":10.8736925125,"time":21}]"
},
{
"date": "01-04-2023",
"counts": "[{"tableCount":9.326757431,"time":11},{"tableCount":9.4327068329,"time":12},{"tableCount":8.0079860687,"time":13},{"tableCount":5.2251749039,"time":14},{"tableCount":2.5511522293,"time":15},{"tableCount":2.8028771877,"time":16},{"tableCount":2.1789927483,"time":17},{"tableCount":3.3140306473,"time":18},{"tableCount":2.8704621792,"time":19},{"tableCount":3.9721398354,"time":20},{"tableCount":7.6661634445,"time":21}]"
},
{
"date": "01-05-2023",
"counts": "[{"tableCount":7.1075911522,"time":11},{"tableCount":5.5151014328,"time":12},{"tableCount":8.0471925735,"time":13},{"tableCount":6.7182812691,"time":14},{"tableCount":8.4082269669,"time":15},{"tableCount":9.8997507095,"time":16},{"tableCount":7.8638906479,"time":17},{"tableCount":9.3877916336,"time":18},{"tableCount":10.8658905029,"time":19},{"tableCount":10.8907938004,"time":20},{"tableCount":8.6171550751,"time":21}]"
},
{
"date": "01-06-2023",
"counts": "[{"tableCount":10.2738752365,"time":11},{"tableCount":11.7885751724,"time":12},{"tableCount":14.5384082794,"time":13},{"tableCount":13.7233953476,"time":14},{"tableCount":10.7814865112,"time":15},{"tableCount":10.6480283737,"time":16},{"tableCount":11.9552650452,"time":17},{"tableCount":12.1137609482,"time":18},{"tableCount":9.6347846985,"time":19},{"tableCount":9.3301410675,"time":20},{"tableCount":8.0276508331,"time":21}]"
},
{
"date": "01-07-2023",
"counts": "[{"tableCount":9.2904233932,"time":11},{"tableCount":10.0985774994,"time":12},{"tableCount":8.670334816,"time":13},{"tableCount":9.018081665,"time":14},{"tableCount":10.2240543365,"time":15},{"tableCount":12.6987085342,"time":16},{"tableCount":10.0400686264,"time":17},{"tableCount":6.4473996162,"time":18},{"tableCount":8.7904291153,"time":19},{"tableCount":9.4310073853,"time":20},{"tableCount":9.7929801941,"time":21}]"
}
],
"x": "",
"note": "predicting without explanation"
}
}
}
},
{
"id": "65260a39bb6b899f4d789223",
"input": {
"fromDate": "12/21/2022",
"toDate": "12/31/2022"
},
"output": {
"data": {
"errorMessage": "",
"traceback": "",
"data": {
"y": [
{
"date": "01-01-2023",
"counts": "[{"tableCount":8.1729021072,"time":11},{"tableCount":9.2272834778,"time":12},{"tableCount":8.7410840988,"time":13},{"tableCount":7.2610864639,"time":14},{"tableCount":4.7990121841,"time":15},{"tableCount":4.9796061516,"time":16},{"tableCount":5.1875333786,"time":17},{"tableCount":6.0545682907,"time":18},{"tableCount":6.2240757942,"time":19},{"tableCount":6.6397485733,"time":20},{"tableCount":6.5043768883,"time":21}]"
},
{
"date": "01-02-2023",
"counts": "[{"tableCount":5.9584774971,"time":11},{"tableCount":4.71900177,"time":12},{"tableCount":5.23458004,"time":13},{"tableCount":5.9814653397,"time":14},{"tableCount":5.5183796883,"time":15},{"tableCount":6.3703117371,"time":16},{"tableCount":3.9970772266,"time":17},{"tableCount":1.6930608749,"time":18},{"tableCount":2.1605021954,"time":19},{"tableCount":2.2661693096,"time":20},{"tableCount":4.5692014694,"time":21}]"
},
{
"date": "01-03-2023",
"counts": "[{"tableCount":4.8561573029,"time":11},{"tableCount":5.6609015465,"time":12},{"tableCount":3.6423728466,"time":13},{"tableCount":4.340628624,"time":14},{"tableCount":7.3471589088,"time":15},{"tableCount":8.417137146,"time":16},{"tableCount":11.6935253143,"time":17},{"tableCount":13.3711690903,"time":18},{"tableCount":12.0397434235,"time":19},{"tableCount":9.6431388855,"time":20},{"tableCount":10.8736925125,"time":21}]"
},
{
"date": "01-04-2023",
"counts": "[{"tableCount":9.326757431,"time":11},{"tableCount":9.4327068329,"time":12},{"tableCount":8.0079860687,"time":13},{"tableCount":5.2251749039,"time":14},{"tableCount":2.5511522293,"time":15},{"tableCount":2.8028771877,"time":16},{"tableCount":2.1789927483,"time":17},{"tableCount":3.3140306473,"time":18},{"tableCount":2.8704621792,"time":19},{"tableCount":3.9721398354,"time":20},{"tableCount":7.6661634445,"time":21}]"
},
{
"date": "01-05-2023",
"counts": "[{"tableCount":7.1075911522,"time":11},{"tableCount":5.5151014328,"time":12},{"tableCount":8.0471925735,"time":13},{"tableCount":6.7182812691,"time":14},{"tableCount":8.4082269669,"time":15},{"tableCount":9.8997507095,"time":16},{"tableCount":7.8638906479,"time":17},{"tableCount":9.3877916336,"time":18},{"tableCount":10.8658905029,"time":19},{"tableCount":10.8907938004,"time":20},{"tableCount":8.6171550751,"time":21}]"
},
{
"date": "01-06-2023",
"counts": "[{"tableCount":10.2738752365,"time":11},{"tableCount":11.7885751724,"time":12},{"tableCount":14.5384082794,"time":13},{"tableCount":13.7233953476,"time":14},{"tableCount":10.7814865112,"time":15},{"tableCount":10.6480283737,"time":16},{"tableCount":11.9552650452,"time":17},{"tableCount":12.1137609482,"time":18},{"tableCount":9.6347846985,"time":19},{"tableCount":9.3301410675,"time":20},{"tableCount":8.0276508331,"time":21}]"
},
{
"date": "01-07-2023",
"counts": "[{"tableCount":9.2904233932,"time":11},{"tableCount":10.0985774994,"time":12},{"tableCount":8.670334816,"time":13},{"tableCount":9.018081665,"time":14},{"tableCount":10.2240543365,"time":15},{"tableCount":12.6987085342,"time":16},{"tableCount":10.0400686264,"time":17},{"tableCount":6.4473996162,"time":18},{"tableCount":8.7904291153,"time":19},{"tableCount":9.4310073853,"time":20},{"tableCount":9.7929801941,"time":21}]"
}
],
"x": "",
"note": "predicting without explanation"
}
}
}
}
]
predict(user_secret, pipeline_key, model_key, from_date, to_date, config, option)
This method is used to get prediction of table count with different model two options available "NEXT_SERIES" and "NEXT_LINK".
| Parameters: |
|
|---|
| Returns: |
|
|---|
Example
from vai_toolkit import model
user_secret='USER_SECRET_KEY'
pipeline_key = 'PIPELINE_KEY'
model_key = 'MODEL_KEY'
from_date = '03/01/2023'
to_date = '05/31/2023'
option = 'NEXT_SERIES'
res = model.predict(user_secret, pipeline_key, model_key ,from_date,to_date,None,option)
print(res)
from vai_toolkit import model
user_secret = 'USER_SECRET_KEY'
pipeline_key = 'PIPELINE_KEY'
model_key ='MODEL_KEY'
config ={
"seedNodeNameCol" : 'ItemDescription',
"prediction" : 10,
"seedNodeNames" : ["1","2"],
"refNodeDict" : {
"GuestCount" :0,
"CheckOpen" : "2023-09-08T05:14:05.283Z",
}}
option ='NEXT_LINK'
res = model.predict(user_secret, pipeline_key, model_key, None,None, config, option)
print(res)
Output
{
{
'data': {
'errorMessage': '',
'traceback': '',
'data': {
'y': [
{'date': '05-31-2023', 'counts': '[{"tableCount":281.7903747559,"time":11},{"tableCount":221.9609527588,"time":12},{"tableCount":136.3621520996,"time":13},{"tableCount":88.3298797607,"time":14}, {"tableCount":66.8720169067,"time":15},{"tableCount":53.803276062,"time":16},{"tableCount":84.1227493286,"time":17},{"tableCount":159.0596923828,"time":18},{"tableCount":186.9671936035,"time":19},{"tableCount":188.2597351074,"time":20},{"tableCount":192.5038146973,"time":21}]'},
{'date': '06-01-2023', 'counts': '[{"tableCount":221.7015228271,"time":11},{"tableCount":249.4067230225,"time":12},{"tableCount":262.0877990723,"time":13},{"tableCount":227.6030883789,"time":14},{"tableCount":163.640625,"time":15},{"tableCount":81.578666687,"time":16},{"tableCount":35.5799293518,"time":17},{"tableCount":25.2485866547,"time":18},{"tableCount":16.2483539581,"time":19},{"tableCount":56.0276679993,"time":20},{"tableCount":127.5245361328,"time":21}]'},
{'date': '06-02-2023', 'counts': '[{"tableCount":151.8760070801,"time":11},{"tableCount":149.3125305176,"time":12},{"tableCount":136.9319000244,"time":13},{"tableCount":138.5372772217,"time":14},{"tableCount":149.87840271,"time":15},{"tableCount":159.7752838135,"time":16},{"tableCount":138.3939819336,"time":17},{"tableCount":101.8885879517,"time":18},{"tableCount":51.3734474182,"time":19},{"tableCount":26.7129077911,"time":20},{"tableCount":25.0917453766,"time":21}]'},
{'date': '06-03-2023', 'counts': '[{"tableCount":15.0687656403,"time":11},{"tableCount":40.74168396,"time":12},{"tableCount":89.7492446899,"time":13},{"tableCount":101.6272888184,"time":14},{"tableCount":98.6197280884,"time":15},{"tableCount":94.0878372192,"time":16},{"tableCount":106.0318145752,"time":17},{"tableCount":128.7826690674,"time":18},{"tableCount":150.5857696533,"time":19},{"tableCount":137.3954925537,"time":20},{"tableCount":107.9107666016,"time":21}]'},
{'date': '06-04-2023', 'counts': '[{"tableCount":69.9748687744,"time":11},{"tableCount":48.4622573853,"time":12},{"tableCount":38.2721862793,"time":13},{"tableCount":23.1030216217,"time":14},{"tableCount":40.9192276001,"time":15},{"tableCount":80.6420669556,"time":16},{"tableCount":88.2661819458,"time":17},{"tableCount":88.1396331787,"time":18},{"tableCount":92.166053772,"time":19},{"tableCount":116.6257400513,"time":20},{"tableCount":148.4887084961,"time":21}]'},
{'date': '06-05-2023', 'counts': '[{"tableCount":169.0198364258,"time":11},{"tableCount":147.4364776611,"time":12},{"tableCount":108.4352493286,"time":13},{"tableCount":58.7132301331,"time":14},{"tableCount":31.183631897,"time":15},{"tableCount":28.5562381744,"time":16},{"tableCount":17.1293258667,"time":17},{"tableCount":44.2518920898,"time":18},{"tableCount":96.2329483032,"time":19},{"tableCount":95.2348632812,"time":20},{"tableCount":85.2216186523,"time":21}]'},
{'date': '06-06-2023', 'counts': '[{"tableCount":89.2415390015,"time":11},{"tableCount":117.0859832764,"time":12},{"tableCount":144.4945983887,"time":13},{"tableCount":158.9694213867,"time":14},{"tableCount":136.0721588135,"time":15},{"tableCount":91.8300094604,"time":16},{"tableCount":37.7490653992,"time":17},{"tableCount":20.4870605469,"time":18},{"tableCount":29.0067577362,"time":19},{"tableCount":17.4881305695,"time":20},{"tableCount":52.84141922,"time":21}]'}
],
'x': '',
'note': 'predicting without explanation'
}
}
}
retrain(user_secret, pipeline_key, model_key)
This method is used to delete model of provided pipeline.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Example
from vai_toolkit import pipeline
user_secret = 'USER_SECRET_KEY'
pipeline_key = 'PIPELINE_KEY'
model_key = 'MODEL_KEY'
res = model.retrain(user_secret, pipeline_key ,model_key)
print(res)
Output
Model retrained successfully.
train(user_secret, pipeline_key, title, from_date, to_date, settings, option, table_name='')
This method is used to train model with options "NEXT_SERIES", "MIXED" and "NEXT_LINK", if "NEXT_SERIES" then model will be trained with timeseries on for given pipeline of user and if "MIXED" then model will be trained with timeseries off for given pipeline of user.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Example
from vai_toolkit import model
user_secret = 'USER_SECRET_KEY'
pipeline_key = 'PIPELINE_KEY'
title = 'MODEL_TITLE'
from_date = '01/01/2022'
to_date = '05/30/2023'
option='NEXT_SERIES'
table_name='Table 1'
res= model.train( user_secret,pipeline_key,title, from_date,to_date, None, option , table_name =table_name)
print(res)
# train mixed model
from vai_toolkit import model
user_secret = 'USER_SECRET_KEY'
pipeline_key = 'PIPELINE_KEY'
title = 'MODEL_TITLE'
from_date = '08/31/2023'
to_date = '09/11/2023'
option='MIXED'
table_name='Table 1'
res= model.train( user_secret,pipeline_key,title, from_date,to_date, None,option , table_name =table_name)
print(res)
from vai_toolkit import model
user_secret = 'USER_SECRET_KEY'
pipeline_key = 'PIPELINE_KEY'
title = 'MODEL_TITLE'
option = 'NEXT_LINK'
settings = {
"dates": {
"dim_item": {
"from": "01-01-2023",
"to": "12-31-2023",
"allDate": False
},
"check": {
"from": "01-01-2023",
"to": "12-31-2023",
"allDate": False
},
"check_item": {
"from": "01-01-2023",
"to": "12-31-2023",
"allDate": False
}
},
"trainNodeType": "check",
"dummyNodeType": "check",
"seedNodeType": "dim_item"
}
res= model.train( user_secret,pipeline_key,title,None,None,settings,option)
print(res)
Output
{
"status": "In progress",
"model Id": "Model Id",
"apiKey": "Model api key."
}
{
"status": "In progress",
"model Id": "Model Id",
"apiKey": "Model api key."
}
{
"status": "In progress",
"model Id": "Model Id",
"apiKey": "Model api key."
}