Retrieve Suggested Config from User Input Via REST API
In some cases, users might wish to get a suggested configuration based on their data without actually exporting their data to Mona. This can now be easily achieved with Mona's /suggest_new_config REST API endpoint.
To access Mona's API, first, an accessToken must be generated and added to the request.
Once users have their accessToken they can add it to their authorization and send a POST request in the following format:
curl --location --request POST 'https://api{YOUR-USER-ID}.monalabs.io/suggest_new_config' \
--header 'Authorization: Bearer YOUR-ACCESS-TOKEN' \
--header 'Content-Type: application/json' \
--data-raw '{
"events": {
"messages": [
{
"arcClass": "{YOUR_CONTEXT_CLASS}",
"contextId": "{contextId}",
"exportTimestamp": {TIMESTAMP},
"message": {
"occupation": "manufacturing",
"city": "Fort Smith",
"state": "Arkansas",
"purpose": "Credit score improvement",
"credit_score": 0.3926368592424558,
"loan_taken": true,
"return_until": 1619948737000,
"offered_amount": 2015,
"approved_amount": 2015,
"stage": "inference",
"model_version": "v1"
}
},
{
"arcClass": "{YOUR_CONTEXT_CLASS}",
"contextId": "{contextId}",
"exportTimestamp": {TIMESTAMP},
"message": {
"feature_0": 2858561.5949184396,
"feature_1": 5.777438394215511,
"feature_2": 762,
"feature_3": 8102,
"feature_4": 0,
"feature_5": 0.9689581447209208,
"feature_6": 27,
"feature_7": 0,
"feature_8": 1384.99655593255,
"feature_9": 18.11042489302702
}
}
]
}
}'
import requests
url = "https://api{YOUR-USER-ID}.monalabs.io/suggest_new_config"
payload={
"events": {
"messages": [
{
"arcClass": "{YOUR_CONTEXT_CLASS}",
"contextId": "{contextId}",
"exportTimestamp": {TIMESTAMP},
"message": {
"occupation": "manufacturing",
"city": "Fort Smith",
"state": "Arkansas",
"purpose": "Credit score improvement",
"credit_score": 0.3926368592424558,
"loan_taken": true,
"return_until": 1619948737000,
"offered_amount": 2015,
"approved_amount": 2015,
"stage": "inference",
"model_version": "v1"
}
},
{
"arcClass": "{YOUR_CONTEXT_CLASS}",
"contextId": "{contextId}",
"exportTimestamp": {TIMESTAMP},
"message": {
"feature_0": 2858561.5949184396,
"feature_1": 5.777438394215511,
"feature_2": 762,
"feature_3": 8102,
"feature_4": 0,
"feature_5": 0.9689581447209208,
"feature_6": 27,
"feature_7": 0,
"feature_8": 1384.99655593255,
"feature_9": 18.11042489302702
}
}
]
}
}
headers = {
'Authorization': 'Bearer YOUR-ACCESS-TOKEN',
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, json=payload)
print(response.text)
from mona_sdk.client import Client
api_key = <YOUR-API-KEY>
secret = <YOUR-SECRET>
my_mona_client = Client(api_key, secret)
my_mona_client.get_suggested_config_from_user_input(
events={
"messages": [
{
"arcClass": "YOUR_CONTEXT_CLASS",
"contextId": "someContextId",
"exportTimestamp": 1644466612,
"message": {
"occupation": "manufacturing",
"city": "Fort Smith",
"state": "Arkansas",
"purpose": "Credit score improvement",
"credit_score": 0.3926368592424558,
"loan_taken": True,
"return_until": 1619948737000,
"offered_amount": 2015,
"approved_amount": 2015,
"stage": "inference",
"model_version": "v1"
}
},
{
"arcClass": "YOUR_CONTEXT_CLASS",
"contextId": "someContextId",
"exportTimestamp": 1644488612,
"message": {
"feature_0": 2858561.5949184396,
"feature_1": 5.777438394215511,
"feature_2": 762,
"feature_3": 8102,
"feature_4": 0,
"feature_5": 0.9689581447209208,
"feature_6": 27,
"feature_7": 0,
"feature_8": 1384.99655593255,
"feature_9": 18.11042489302702
}
}
]
}
)
The response for this call will be a list of all new sources still unused by Mona and a suggested configuration that includes existing fields in this class and the new fields exported now.
{
"unused_sources": {
"YOUR_CONTEXT_CLASS": [
{
"field_name": "approved_amount",
"field_possible_types": [
"numeric",
"string"
]
},
{
"field_name": "city",
"field_possible_types": [
"string"
]
},
{
"field_name": "credit_score",
"field_possible_types": [
"numeric",
"string"
]
},
{
"field_name": "feature_0",
"field_possible_types": [
"numeric",
"string"
]
},
{
"field_name": "feature_1",
"field_possible_types": [
"numeric",
"string"
]
},
{
"field_name": "feature_2",
"field_possible_types": [
"numeric",
"string"
]
},
{
"field_name": "feature_3",
"field_possible_types": [
"numeric",
"string"
]
},
{
"field_name": "feature_4",
"field_possible_types": [
"boolean",
"numeric",
"string"
]
},
{
"field_name": "feature_5",
"field_possible_types": [
"numeric",
"string"
]
},
{
"field_name": "feature_6",
"field_possible_types": [
"numeric",
"string"
]
},
{
"field_name": "feature_7",
"field_possible_types": [
"boolean",
"numeric",
"string"
]
},
{
"field_name": "feature_8",
"field_possible_types": [
"numeric",
"string"
]
},
{
"field_name": "feature_9",
"field_possible_types": [
"numeric",
"string"
]
},
{
"field_name": "loan_taken",
"field_possible_types": [
"boolean",
"numeric",
"string"
]
},
{
"field_name": "model_version",
"field_possible_types": [
"string"
]
},
{
"field_name": "occupation",
"field_possible_types": [
"string"
]
},
{
"field_name": "offered_amount",
"field_possible_types": [
"numeric",
"string"
]
},
{
"field_name": "purpose",
"field_possible_types": [
"string"
]
},
{
"field_name": "return_until",
"field_possible_types": [
"numeric",
"string"
]
},
{
"field_name": "stage",
"field_possible_types": [
"string"
]
},
{
"field_name": "state",
"field_possible_types": [
"string"
]
}
]
},
"suggested_config": {
"YOUR_USER_ID": {
"YOUR_CONTEXT_CLASS": {
"fields": {
"approved_amount": {
"type": "numeric",
"segmentations": {
"original": {
"default": true,
"bucket_size": 1
}
}
},
"city": {
"type": "string"
},
"credit_score": {
"type": "numeric",
"segmentations": {
"original": {
"default": true,
"bucket_size": 1
}
}
},
"feature_0": {
"type": "numeric",
"segmentations": {
"original": {
"default": true,
"bucket_size": 1
}
}
},
"feature_1": {
"type": "numeric",
"segmentations": {
"original": {
"default": true,
"bucket_size": 1
}
}
},
"feature_2": {
"type": "numeric",
"segmentations": {
"original": {
"default": true,
"bucket_size": 1
}
}
},
"feature_3": {
"type": "numeric",
"segmentations": {
"original": {
"default": true,
"bucket_size": 1
}
}
},
"feature_4": {
"type": "boolean"
},
"feature_5": {
"type": "numeric",
"segmentations": {
"original": {
"default": true,
"bucket_size": 1
}
}
},
"feature_6": {
"type": "numeric",
"segmentations": {
"original": {
"default": true,
"bucket_size": 1
}
}
},
"feature_7": {
"type": "boolean"
},
"feature_8": {
"type": "numeric",
"segmentations": {
"original": {
"default": true,
"bucket_size": 1
}
}
},
"feature_9": {
"type": "numeric",
"segmentations": {
"original": {
"default": true,
"bucket_size": 1
}
}
},
"loan_taken": {
"type": "boolean"
},
"model_version": {
"type": "string"
},
"occupation": {
"type": "string"
},
"offered_amount": {
"type": "numeric",
"segmentations": {
"original": {
"default": true,
"bucket_size": 1
}
}
},
"purpose": {
"type": "string"
},
"return_until": {
"type": "numeric",
"segmentations": {
"original": {
"default": true,
"bucket_size": 1
}
}
},
"stage": {
"type": "string"
},
"state": {
"type": "string"
}
}
}
}
}
}
Updated 25 days ago