Wednesday, 11 December 2013

Registering and executing statistical models



nanobi analytics platform comes with a few built-in predictive models. These are time series forecasting, classification, association rules, regression and outlier detection.

These can be used as usual analytics with specified declarative options. This needs no R or SAS programming.

However, for advanced statistical modelling requirements, there is way to register bespoke models. After the nanomart is created, register the model and then execute the model. The results are seen in the usual way (analytics and hives).

These operations can be done through UI or programmatically using the REST Web services. This post shows the pertinent web services.

It is assumed that authentication is already done and token is available. The auth token can then be used to call the usual metadata APIs to get AppIDs and MartIDs.

Armed with this, we can start working with model scripts.

Getting a list of mart scripts and models

GET
<server url>/DataObjectServer/data/do?ot=ast&an=nbmdc_nanomarts_row_id&av=<mart id>&o==&tokenid=<auth token>

Example response:
{
                "ast":
                [
                {
                                "row_id": "fdffcd9d-f50a-4b14-9b4d-712abe49c34c",
                                "is_applied": "n",
                                "describe_name": "",
                                "icon_content": null,
                                "si_id": "106319b8-d03f-402c-a58e-e993d872a233",
                                "icon_path": null,
                                "updated_by_user_id": null,
                                "file_name": "ms_8b244f93-1bdd-43ea-9fef-d0f7cd50eae0_1_vbwyKFHdDYBEkfM.R",
                                "created_by_user_id": "a15cd765-ead8-4794-a32d-ab17bb826ae7",
                                "subscript_type": "R Script",
                                "nbmdc_assets": "my r code",
                                "script_type": "batchcommand",
                                "description": "my r code",
                                "sequence": "1",
                                "nbmdc_nanomarts_row_id": "8b244f93-1bdd-43ea-9fef-d0f7cd50eae0",
                                "created_datetime": "2013-12-10 04:39:58",
                                "active_flag": "y"
                },
                {
                                "row_id": "3cf08efb-c714-473d-bf69-a294fac6caad",
                                "is_applied": "y",
                                "describe_name": "",
                                "icon_content": null,
                                "si_id": "106319b8-d03f-402c-a58e-e993d872a233",
                                "icon_path": null,
                                "updated_by_user_id": null,
                                "file_name": "ms_8b244f93-1bdd-43ea-9fef-d0f7cd50eae0_0_kQTgGZHUMhEFJUg.R",
                                "created_by_user_id": "a15cd765-ead8-4794-a32d-ab17bb826ae7",
                                "subscript_type": "R Script",
                                "nbmdc_assets": "testing r",
                                "script_type": "batchcommand",
                                "description": "testing r",
                                "sequence": "0",
                                "nbmdc_nanomarts_row_id": "8b244f93-1bdd-43ea-9fef-d0f7cd50eae0",
                                "created_datetime": "2013-12-09 07:31:14",
                                "active_flag": "y"
                }
                ]
}

Note: Not that you care, but if you are wondering, "ast" is short for "asset". A model script is internally stored as a mart asset.

Registering a mart script

POST <server url>/NanoClientApplication/martMaintanence
Parameters:
scriptDescription   my r code
script_type batchcommand
subscript_type R Script
scriptSequence 1
via url
fileUpload
fileUrl url/t.R
is_applied n
created_by_user_id a15cd765-ead8-4794-a32d-ab17bb826ae7
martid 8b244f93-1bdd-43ea-9fef-d0f7cd50eae0
si_id 106319b8-d03f-402c-a58e-e993d872a233
token 0e9a4d40-e695-453b-854c-0330313236b3

Response:
[{
                "statusCode": "0",
                "statusMessage": "Maintenance script executed."
}]


Note: While executing the script, the following built-in parameters are supported. They need not be explicitly passed to the script.
$mart_db
$mart_user
$mart_pwd
$mart_db_url

These parameters can be used in the script and are internally replaced by their values.
Additional command line parameters can be passed when executing the script.

Executing a script

POST
<server url>/DataObjectServer/data/do/serverCommand/execute
Parameters:
tokenid   0e9a4d40-e695-453b-854c-0330313236b3
parameter {"id":"fdffcd9d-f50a-4b14-9b4d-712abe49c34c"}

Response:
[{
                "statusCode": "0",
                "statusMessage":
"Successfully executed command.status file url:server/statusFiles/nNFGqJAqSTrtDtF.out"
}]






3 comments:

  1. Updating with the latest technology and implementing it is the only way to survive in our niche. Thanks for making me this article. You have done a great job by sharing this content in here. Keep writing article like this.
    SAS Training in Chennai | SAS Course in Chennai

    ReplyDelete
  2. Hello admin, I have read your blog. Really very informative and useful for me. SAS is a lead in business analytics. Through advanced analytics it caters to data management and business intelligence software and services. To increase your business ROI learn SAS Training in Bangalore

    ReplyDelete